简体   繁体   English

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

[英]How to create contracts on Ethereum block-chain in python?

I want to create contract on Ethereum to store data. 我想在以太坊上创建合约来存储数据。 I'm beginner on this domain...Do we have a better solution ? 我是这个领域的初学者...我们有更好的解决方案吗?

In this post , someone tell me to download a plugin. 在这篇文章中 ,有人告诉我要下载插件。 This is one way to do it, but I want to insert data in a block-chain with python (or other language). 这是一种实现方法,但是我想使用python(或其他语言)在块链中插入数据。

I don't know where to start ... download Ethereum? 我不知道从哪里开始...下载以太坊? Create an account? 创建一个帐户?

Does it incur any cost? 它会产生任何费用吗? How much? 多少?

If contracts can be update, can I use Ethereum contract to prove work? 如果可以更新合同,我可以使用以太坊合同来证明工作吗?

I don't know where to start ... download Ethereum? 我不知道从哪里开始...下载以太坊? Create an account? 创建一个帐户?

  1. Install the command line tools. 安装命令行工具。 ethereum.org/cli ethereum.org/cli

    I would not recommend to start with the pyethapp (Python) or the eth (C++) client. 我不建议从pyethapp (Python)或eth (C ++)客户端开始。 Use geth (Golang) or parity (Rust). 使用geth (Golang)或parity (Rust)。 They are good to get started with and well documented. 他们是很好的入门指南并有据可查。

  2. Create a hello world contract. 创建一个hello world合同。 ethereum.org/greeter ethereum.org/greeter

    greeter is the most simple smart contract deployed using the command line. 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. Come back here if you have specific issues with a client, with a contract source code or with deploying them on the blockchain. 如果您与客户,合同源代码或在区块链上部署有特定问题,请回到此处。

Hope that helps getting you bootstrapped :) 希望能帮助您入门:)

You may also use (py)ethereum and serpent - in order to keep the python spirit - If it is ok for you, you may take a look at " A Programmer's Guide to Ethereum and Serpent ". 您还可以使用(py)ethereum -为了保持python的精神-如果可以的话,您可以看一下《 以太坊和蛇的程序员指南 》。 Regards 问候

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

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