簡體   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