Skip to content

Instantly share code, notes, and snippets.

View vibern0's full-sized avatar
🥸
do you even blockchain?

Bernardo vibern0

🥸
do you even blockchain?
View GitHub Profile
{
"age": 28,
"sex": "M",
"city": "Paris",
"work": "none",
"hospital_entries_last_year": [
{
"date": "7/12",
"situation": "fever",
}
await window.ethereum.enable();
const web3 = new Web3(window.ethereum);
// 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);
// Get the contract instance.
const Contract = truffleContract(SimpleStorageContract);
Contract.setProvider(web3.currentProvider);
const simpleContract = await Contract.deployed();
import truffleContract from '@truffle/contract';
import SimpleStorageContract from '../../build/contracts/SimpleStorage.json';
simpleContract.methods.set(123).send({ from: 'your-account-address'}).then(console.log);
simpleContract.methods.get().call().then(console.log);
const yourContractAbi = [...];
const yourContractAddress = '0xf2Dee5975A808f16f93bf4Fd55aB5481a8B20497';
const simpleContract = new web3.eth.Contract(yourContractAbi, yourContractAddress);
new web3.eth.Contract(jsonInterface[, address][, options])