Solidity

Getting the address of a contract deployed by another contract

耗尽温柔 提交于 2019-12-03 12:53:07
问题 I am trying to deploy a contract from another factory contract and then return the address of the newly created contract. The address it returns however is the transaction hash not the contract address. I believe this is because the contract is not yet mined when the address is returned. When I deploy a contract using the web3 deploy it seems to wait until the contract is deployed before outputting the address. The factory contract: contract Factory { mapping(uint256 => Contract)

solidity 0.5.7简明教程

霸气de小男生 提交于 2019-12-03 11:18:09
以太坊不仅是一种加密数字货币,它更是功能完备的智能合约平台,solidity就是用来开发以太坊上的智能合约的原生开发语言。solidity最早发布于2015年,它是第一种图灵完备的智能合约专用开发语言。目前除了以太坊之外,在其他区块链中也逐渐开始支持solidity,例如hyperledger fabric、tendermint等。在这个solidity快速教程中,我们将使用最新0.5.7版的solidity,以一个具体的案例来介绍solidity智能合约的开发、部署与交互,希望对你快速掌握solidity智能合约的开发有所帮助。 如果要高效系统地掌握以太坊智能合约与DApp的开发,推荐访问汇智网的在线互动课程: 以太坊开发入门 | java以太坊 | python以太坊 | php以太坊 | C#以太坊 | 电商DApp实战 | ERC721通证实战 0、问题的背景 有一个老爷爷,在生命的最后岁月别无他求,只是希望自己的财产能够通过遗嘱顺利地传给其他家庭成员。 在传统的遗嘱中,遗产分配方案是落实在法律文件上的,然后当真正开始分配时,法官需要重审文件并做出相应的决定。常见的问题发生在家庭成员之间对分配比例的争执上,甚至因此而导致家庭成员关系的破裂。在法庭听证阶段,这些都会影响法官最终的裁决,并因此可能导致不公平的结果,甚至对家庭关系造成进一步的伤害。 那么

solidity教程【0.5.7】

落爺英雄遲暮 提交于 2019-12-03 11:16:02
以太坊不仅是一种加密数字货币,它更是功能完备的智能合约平台,solidity就是用来开发以太坊上的智能合约的原生开发语言。solidity最早发布于2015年,它是第一种图灵完备的智能合约专用开发语言。目前除了以太坊之外,在其他区块链中也逐渐开始支持solidity,例如hyperledger fabric、tendermint等。在这个solidity快速教程中,我们将使用最新0.5版的solidity,以一个具体的案例来介绍solidity智能合约的开发、部署与交互,希望对你快速掌握solidity智能合约的开发有所帮助。 如果要高效系统地掌握以太坊智能合约与DApp的开发,推荐访问汇智网的在线互动课程: 以太坊开发入门 | java以太坊 | python以太坊 | php以太坊 | C#以太坊 | 电商DApp实战 | ERC721通证实战 0、问题的背景 有一个老爷爷,在生命的最后岁月别无他求,只是希望自己的财产能够通过遗嘱顺利地传给其他家庭成员。 在传统的遗嘱中,遗产分配方案是落实在法律文件上的,然后当真正开始分配时,法官需要重审文件并做出相应的决定。常见的问题发生在家庭成员之间对分配比例的争执上,甚至因此而导致家庭成员关系的破裂。在法庭听证阶段,这些都会影响法官最终的裁决,并因此可能导致不公平的结果,甚至对家庭关系造成进一步的伤害。 那么

How to find out if an Ethereum address is a contract?

旧时模样 提交于 2019-12-03 05:47:42
问题 An address in Solidity can be an account or a contract (or other things, such as a transaction). When I have a variable x, holding an address, how can I test if it is a contract or not? (Yes, I've read the chapter on types in the doc) 回答1: Edit: Solidity has changed since this answer was first written, @manuel-aráoz has the correct answer. There is no way in solidity to check if an address is a contract. One of the goals of Ethereum is for humans and smart contracts to both be treated equally

Are there null like thing in solidity

淺唱寂寞╮ 提交于 2019-12-03 05:00:21
struct buyer{ uint amount; Status status; } mapping(address=>buyer) public buyers; mapping(uint=>address) buyerIndex; uint public buyerNum; //Order a product. function(){ uint doubleValue=value*2; uint amount=msg.value/doubleValue; if(buyers[msg.sender]==null){ //Error in this line buyer abuyer=buyer({amount:amount,status:Status.Created}); //Error in this line buyerNum++; buyerIndex[buyerNum]=msg.sender; buyers[msg.sender]=abuyer; }else{ buyers[msg.sender].amount+=amount; } Order(msg.sender,amount*doubleValue,amount); } If a buyer is not recorded in the buyer mapping, then buyerNum++; but I

Getting the address of a contract deployed by another contract

此生再无相见时 提交于 2019-12-03 03:24:55
I am trying to deploy a contract from another factory contract and then return the address of the newly created contract. The address it returns however is the transaction hash not the contract address. I believe this is because the contract is not yet mined when the address is returned. When I deploy a contract using the web3 deploy it seems to wait until the contract is deployed before outputting the address. The factory contract: contract Factory { mapping(uint256 => Contract) deployedContracts; uint256 numContracts; function Factory(){ numContracts = 0; } function createContract (uint32

2天闭门培训|以太坊智能合约从入门到实战(北京)

三世轮回 提交于 2019-12-03 00:51:48
2天培训 16个课时 探寻技术原理,精通以太坊智能合约开发 以太坊智能合约是现在应用的最广泛的区块链应用开发方式,HiBlock区块链社区针对以太坊智能合约的学习特别推出2天闭门研修班,通过2天16个课时,学习掌握以太坊智能合约从基础入门到开发实践。 1月19-20日,由HiBlock区块链社区发起人Bob Jiang老师以及以太坊专家杨镇老师联合授课。 本次课程从以太坊智能合约基础讲起,覆盖2个区块链应用的动手实践以及区块链投票、拍卖、在线支付等智能合约实例的讲解,在2天时间里由浅入深掌握区块链智能合约开发。 1 时间地点 **开课时间:**1月19日-1月20日 (每天9:00-17:00) **开课地点:**北京市朝阳区富华大厦D-4B **报名费用:**原价2800元/人, 限时优惠价1800元/人 ( 注 :本课程招生名额有限,一旦报名不接受因学员自身原因产生的退款,报名请准时到场。) 学员自带电脑 可加微信咨询,微信号:EF0815。好友申请输入:线下培训 2 课程内容 1月19日:掌握以太坊:实践驱动智能合约学习 内容简介: 第一天共计8个课时(45分钟/课时),BoB Jiang老师对区块链相关概念进行介绍,帮助学习者掌握以太坊基础概念及智能合约Dapp开发,并介绍Solidity语言基础。通过6个课时进行2个具体项目的动手实践,在开发过程中掌握智能合约开发技巧

Different ways to invoke contract method

杀马特。学长 韩版系。学妹 提交于 2019-12-02 08:59:19
I have one contract with method name as getValues().From Dapp I am invoking contract method as 'contractCAt.getValues.call(function(error,result){...})' this works fine and by using 'contractCAt.getValues(function(error,result){...})' this syntax also works fine.I didn't get any difference between those two ways to invoke contract method.So could anyone help me to give idea about those syntax. See the web3j documentation : contractCAt.getValues.call() is run locally and will not alter the state of your contract on the blockchain. Does not consume any ether. contractCAt.getValues

RuntimeError: Can not reuse socket after connection was closed using docker

两盒软妹~` 提交于 2019-12-02 08:11:07
I am following this tutorial to run Ethereum crawler using Docker on window 10 using docker after executing $ MYSQL_DATA_PATH="$HOME/indexer-data/mysql" GETH_DATA_PATH="$HOME/indexer-data/geth"docker-compose up in this line i got error 409 Client Error: Conflict for url: http+docker://localnpipe/v1.25/containers/ee2b46142bae704d4963853e22a77ba896a8f841120ecf5ac97befca91847672/attach?logs=0&stdout=1&stderr=1&stream=1 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "threading.py", line 916, in _bootstrap_inner File "threading.py", line

使用修饰符让Solidity开发以太坊智能合约有更好的可读性

给你一囗甜甜゛ 提交于 2019-12-02 04:21:32
修饰符是可以应用于其他函数的一个函数。在调用函数之前,确保满足某些先决条件非常有用。我们举一个简单的例子,在我们已经写过的合约中,我们经常要检查函数的调用者是否是合约的所有者: function increment() public { if (owner == msg.sender) { // We check who calls the function count = count + 1; } } 想象一下,如果我们的智能合约有多个只能由所有者调用的函数,那么如果 owner == msg.sender 部分需要重构那么怎么做?这是修饰语将帮助我们的地方。让我们看第一个修饰符: modifier isAdmin() { require(msg.sender == owner); _; } function increment() public isAdmin { count = count + 1; } 我们的修饰符看起来像一个函数。 require() 函数评估条件,如果不满足条件将抛出异常,这将停止执行我们的智能合约。 _ 关键字告诉编译器用函数体替换 _ 。 与函数一样,修饰符可以接受参数。假设我们可以拥有多个用户,并希望检查所有权,看下面的代码: modifier onlyBy(address _account) { require(msg.sender ==