繁体   English   中英

坚固性0.4.6中使用send()函数时,合同抛出无效地址

[英]Contract throws Invalid address when using send() function in solidity 0.4.6

这是我正在尝试的代码。 代码的编译工作正常。 但是,当我通过javascript调用函数send()时,它抛出异常:throw new Error('invalid address');

pragma solidity ^0.4.6; 
contract Agreement {
   address owner;
   address seller; 
   uint amount; 

   function Agreement(address _seller,uint _amount) {
     owner = msg.sender; seller=_seller; amount=_amount;
   } 

   function send(){
    if (owner.balance < amount) throw;      
    if (seller.balance + amount < seller.balance) throw;
    if(!seller.send(amount))throw;
    } 
}

这是JavaScript代码

var compiled = web3.eth.compile.solidity(contractRaw);
var contract = web3.eth.contract(compiled.info.abiDefinition);
var nContract = contract.new('0x61e323dcf5e116597d96558a91601f94b1f80396',web3.toWei(10, "ether"),{from:this.web3.eth.coinbase, data: compiled.code, gas: 380000}, function(e, contractDetails){
        if(!e) {

            if(!contractDetails.address) {
                console.log("Contract transaction send: TransactionHash: " + contractDetails.transactionHash + " waiting to be mined...");

            } else {
                console.log("Contract mined! Address: " + contractDetails.address);
                console.log(contractDetails.send())

            }

        }
    });

每当代码运行时,它将引发无效的地址错误并崩溃。

该地址实际上存在( etherscan链接 )>,但它不是合同地址。 如果是,必须打开这样

将合同部署到etherium时,必须复制创建合同时产生的哈希(事务哈希)并在etherscan上搜索。 它将打开所有交易明细,包括创建的合同哈希。 使用该哈希。

尝试61e323dcf5e116597d96558a91601f94b1f80396 ,而不使用0x

暂无
暂无

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

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