Published
Edited
Nov 8, 2019
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ethereum.enable()
Insert cell
Insert cell
Insert cell
Insert cell
Web3js = require("https://cdn.jsdelivr.net/gh/ethereum/web3.js@1.2.0/dist/web3.min.js")
Insert cell
Insert cell
Insert cell
web3js = new Web3js(web3.currentProvider)
Insert cell
Insert cell
Insert cell
transaction = ({
from: web3js.givenProvider.selectedAddress,
to: "0x07D62a36D35261AfEcF6cb89382D393a398edc1a",
value: web3js.utils.toWei("0.01", "ether")
})
Insert cell
Insert cell
web3js.eth.sendTransaction(transaction)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
web3js.eth.getBalance(web3js.givenProvider.selectedAddress)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ABI = [
{
"constant": false,
"inputs": [
{
"internalType": "uint256",
"name": "x",
"type": "uint256"
}
],
"name": "set",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "uint256",
"name": "newValue",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "updatedBy",
"type": "address"
}
],
"name": "storageUpdate",
"type": "event"
},
{
"constant": true,
"inputs": [],
"name": "get",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
}
]
Insert cell
Insert cell
simpleStorage = new web3js.eth.Contract(ABI, simpleStorageAddress)
Insert cell
Insert cell
Insert cell
Insert cell
simpleStorage.methods.get().call()
Insert cell
Insert cell
Insert cell
Insert cell
simpleStorage.methods.set(42).send({from: web3js.givenProvider.selectedAddress})
Insert cell
Insert cell
Insert cell
Insert cell
simpleStorage.events.storageUpdate((error, event) =>console.log(event))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more