Example javascript library which can be used to communicate with the Ethereum network via localnode, metamask or custom node URL.
-
Include script files web.min.js and contractInterface.js in HTML file.
-
Call the ContractInterface contract function with the solidity-contract-function-name and arguments array.
const contractInterface = new ContractInterface(); contractInterface.contract('solidity_function_name', []).then((res) => { console.log(res); }, (err) => { console.log(err); }); contractInterface.contract('solidity_function_name', ['one', 'two']).then((res) => { console.log(res); }, (err) => { console.log(err); });
*Note: In contractInterface.js change the contractAddress to your deployed contract address and abiAddress to your abi.json file location.
Web3.js