-
-
Save NaoyaTabakomori/98077ed8e38afe8b60bd07960e435921 to your computer and use it in GitHub Desktop.
Letter.solの解法
This file contains 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
var fs = require('fs'); | |
var Web3 = require('web3'); | |
var web3 = new Web3('wss://ropsten.infura.io/ws'); | |
var letterABI = JSON.parse(fs.readFileSync('./build/contracts/Letter.json')).abi; | |
var letterAddress = '0xbaDE12c0bd7943A066e77f0466D529D78d2F70dB'; | |
var letter = new web3.eth.Contract(letterABI, letterAddress); | |
var address = 'your address'; | |
var privkey = 'your priv key'; | |
sealLetter() | |
async function sealLetter() { | |
web3.eth.defaultAccount = address; | |
web3.eth.accounts.wallet.add(privkey); | |
var balance; | |
// balanceの確認 | |
balance = await letter.methods.balanceOf(address).call(); | |
console.log(balance); | |
// fallback関数の呼び出し | |
await web3.eth.sendTransaction({ | |
from: 0, | |
to: letterAddress, | |
value: 1, | |
gas: 50000, | |
}); | |
// balanceの確認 | |
balance = await letter.methods.balanceOf(address).call(); | |
console.log(balance); | |
// seal | |
var seal = await letter.methods.seal().send({ | |
from: address, | |
gas: 50000, | |
}); | |
console.log(seal); | |
// sealされているかの確認 | |
var sealed = await letter.methods.isSealed(address).call(); | |
console.log(sealed); | |
web3.currentProvider.connection.close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment