Knowledge dump for Solidity and Javascript

To get a Solidity contract's ABI, paste the contract into the Remix online Solidity compiler, click Compile, and click on Details. The ABI is then under the Interface panel.

This can then be directly assigned to a variable in Javascript, without any string quoting, as it is a Javascript array.

var ContractABI = [......];
var ContractInstance = web3.eth.contract(ContractABI);
var ContractAddr = "0x.....";
contract = ContractInstance.at(ContractAddr);

 

Published Wed, 1 Nov 2017 @ 9:13 PM by chuacw
Related articles: ,