Skip to content

Commit

Permalink
web3 in 2 mins
Browse files Browse the repository at this point in the history
  • Loading branch information
jklepatch committed Oct 22, 2021
1 parent c3c0128 commit e749714
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions screencast/420-web3-in-2-mins/MyContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma solidity 0.8.0;

contract MyContractol {
uint data;

function read() external view returns(uint) {
return data;
}

function write(uint _data) external {
data = _data;
}
}
17 changes: 17 additions & 0 deletions screencast/420-web3-in-2-mins/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Web3 = require('web3');

const web3 = new Web3('https://mainnet.infura.io/v3/ed18016b210c4a1baf828458bd16feb0');

web3.eth.accounts.wallet.add('0x55d0380decced82a2198582e541a129e8b86937c30a1c51bbb5327b9f00c6aa4');

web3.eth.getBalance('0xFA17F09e8464Bd0c592Daf09bf285B5cD72Bec3D')
.then(balance => console.log(balance));

const contract = new web3.eth.Contract(abi, '0x6E62c6e07019Bc3db5554a8d602390C6CC0B7846');

contract.methods.read().call()
.then(result => console.log(result));

web3.eth.sendTransaction({from: '0xFA17F09e8464Bd0c592Daf09bf285B5cD72Bec3D', value: 1000})

contract.methods.write().sendTransaction({from: '0xFA17F09e8464Bd0c592Daf09bf285B5cD72Bec3D'});

0 comments on commit e749714

Please # to comment.