如何用python在以太坊区块链上创建合约



我想在以太坊上创建合约来存储数据。我是这个领域的初学者…我们有更好的解决方案吗?

在这篇文章中,有人告诉我下载一个插件。这是一种方法,但我想用python(或其他语言)在区块链中插入数据。

我不知道从哪里开始…下载Ethereum ?创建帐户?

会产生任何费用吗?多少钱?

如果合约可以更新,我可以使用以太坊合约来证明工作吗?

我不知道从哪里开始…下载Ethereum ?创建帐户?

  1. 安装命令行工具。ethereum.org/cli

    我不建议从pyethapp (Python)或eth (c++)客户机开始。使用geth (Golang)或parity (Rust)。

  2. 创建hello world契约。ethereum.org/greeter

    greeter是使用命令行部署的最简单的智能合约。

    contract mortal {
        /* Define variable owner of the type address*/
        address owner;
        /* this function is executed at initialization and sets the owner of the contract */
        function mortal() { owner = msg.sender; }
        /* Function to recover the funds on the contract */
        function kill() { if (msg.sender == owner) selfdestruct(owner); }
    }
    contract greeter is mortal {
        /* define variable greeting of the type string */
        string greeting;
        /* this runs when the contract is executed */
        function greeter(string _greeting) public {
            greeting = _greeting;
        }
        /* main function */
        function greet() constant returns (string) {
            return greeting;
        }
    }
    
  3. 如果您与客户端有特定的问题,合同源代码或将它们部署到区块链上,请回到这里。

希望能帮到你:)

你也可以使用(py)ethereum和serpent -为了保持python的精神-如果对你来说可以的话,你可以看看"一个程序员的指南以太坊和蛇"。关于

最新更新