This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "age": 28, | |
| "sex": "M", | |
| "city": "Paris", | |
| "work": "none", | |
| "hospital_entries_last_year": [ | |
| { | |
| "date": "7/12", | |
| "situation": "fever", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| await window.ethereum.enable(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const web3 = new Web3(window.ethereum); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Stores a given value, 5 by default. | |
| simpleContract.set(5, { from: 'your-account-address' }).then(console.log); | |
| // Get the value from the contract to prove it worked. | |
| simpleContract.get().then(console.log); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get the contract instance. | |
| const Contract = truffleContract(SimpleStorageContract); | |
| Contract.setProvider(web3.currentProvider); | |
| const simpleContract = await Contract.deployed(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import truffleContract from '@truffle/contract'; | |
| import SimpleStorageContract from '../../build/contracts/SimpleStorage.json'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| simpleContract.methods.set(123).send({ from: 'your-account-address'}).then(console.log); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| simpleContract.methods.get().call().then(console.log); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const yourContractAbi = [...]; | |
| const yourContractAddress = '0xf2Dee5975A808f16f93bf4Fd55aB5481a8B20497'; | |
| const simpleContract = new web3.eth.Contract(yourContractAbi, yourContractAddress); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| new web3.eth.Contract(jsonInterface[, address][, options]) |