November 2018
Intermediate to advanced
528 pages
13h 21m
English
Ethereum provides us with web3.js, which is a useful API to make the web developer's life easier. This JavaScript API enables us to communicate with an Ethereum node using JSON RPC endpoints exposed on top of HTTP, WebSocket, and/or IPC transports from a web page.
In auction.js, copy and paste the following code, so we can walk through it step by step while introducing the main web3.js features:
var web3 = new Web3();web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));var bidder = web3.eth.accounts[0];web3.eth.defaultAccount = bidder;var auctionContract = web3.eth.contract("Here the contract's ABI"); // ABI omitted to make the code concisefunction bid() { var mybid = document.getElementById('value').value; ...Read now
Unlock full access