我是新的区块链,直到现在,我已经设法部署合同,并通过geth控制台和节点代码传输以太.我现在正试图弄清楚如何获得我已经部署的合同,并通过Geth和javascript与其交互.我会感谢你的帮助。
谢谢!:)
发布于 2016-09-01 08:19:18
下面是您需要的主要步骤的示例。您需要ABI (从编译契约时开始)和部署到的地址。
https://github.com/ethereum/wiki/wiki/JavaScript-API#example-50
// contract abi
var abi = [{
name: 'myConstantMethod',
type: 'function',
constant: true,
inputs: [{ name: 'a', type: 'string' }],
outputs: [{name: 'd', type: 'string' }]
}, {
name: 'myStateChangingMethod',
type: 'function',
constant: false,
inputs: [{ name: 'a', type: 'string' }, { name: 'b', type: 'int' }],
outputs: []
}, {
name: 'myEvent',
type: 'event',
inputs: [{name: 'a', type: 'int', indexed: true},{name: 'b', type: 'bool', indexed: false}]
}];
// creation of contract object
var MyContract = web3.eth.contract(abi);
// initiate contract for an address
var myContractInstance = MyContract.at('0xc4abd0339eb8d57087278718986382264244252f');
// call constant function
var result = myContractInstance.myConstantMethod('myParam');
console.log(result) // '0x25434534534'https://ethereum.stackexchange.com/questions/8458
复制相似问题