合同抛出在solidity 0.4.6中使用send()函数时的地址无效

时间:2017-04-24 21:45:27

标签: javascript ethereum solidity web3js

这是我正在尝试的可靠性代码。编译代码工作正常。但是,当我通过javascript调用函数send()时会抛出异常:抛出新错误('无效地址');

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())

            }

        }
    });

每当代码运行时,它都会抛出无效的地址错误并崩溃。

2 个答案:

答案 0 :(得分:0)

该地址实际上存在(etherscan link)&gt; ,但这不是合同地址。如果是,则必须打开like this

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

答案 1 :(得分:-1)

尝试61e323dcf5e116597d96558a91601f94b1f80396,不使用0x