简体   繁体   English

Solidity 智能合约引擎

[英]Solidity smart contract engine

We're building our own blockchain for a school project.我们正在为学校项目构建自己的区块链。 My part is to implement Solidity smart contracts on the blockchain.我的部分是在区块链上实施 Solidity 智能合约。 The idea was to put a Solidity smart contract engine on the validator nodes, but after weeks of searching and trying different engines I can't find a right one.这个想法是在验证器节点上放置一个 Solidity 智能合约引擎,但经过数周的搜索和尝试不同的引擎后,我找不到合适的引擎。 Do you have any recommendations for a Solidity smart contract engine?您对 Solidity 智能合约引擎有什么建议吗? Thanks.谢谢。

Smart Contracts are execute in EVM Ethereum Virtual Machine.智能合约在 EVM 以太坊虚拟机中执行。 EVM is totally isolated and has no contact with the node. EVM 是完全隔离的,与节点没有任何联系。 The validation process of transaction is done on the node level.交易的验证过程是在节点级别完成的。 So what you are looking for is the EVM which perfom these actions.因此,您正在寻找的是执行这些操作的 EVM。

Now if you want to implement the blockchain one easiest way is to use TestRpc that will create the in memory blockchain where you can deploy the transaction and perform transaction.现在,如果您想实现区块链,一种最简单的方法是使用 TestRpc,它将创建内存区块链,您可以在其中部署交易并执行交易。 The validation of transaction is done internally in blockchain.交易的验证在区块链内部完成。

You can use the factory pattern and create your own "engine" with built in new.您可以使用工厂模式并使用内置的 new 创建您自己的“引擎”。

contract RBACFactory{
    address[] public deployedEntities;

    function createEntity(string memory name, string memory mission, string memory tokenName, 
                          string memory tokenSymbol, uint rate) public {
        address newEntity = address(new Entity(name, mission, msg.sender, tokenName, tokenSymbol, rate));
        deployedEntities.push(address(newEntity));
      
    }
    function getDeployedEntities() public view returns(address[] memory) {
        return deployedEntities;
    }
}

I am doing the same and i use truffle framework and ganache local blockchain.我也在做同样的事情,我使用松露框架和 ganache 本地区块链。 It is very easy to deploy smart contract and interact with it.部署智能合约并与之交互非常容易。

See: truffle suite参见:松露套房

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM