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
const { ContractFactory, ethers, Signer } = require("ethers"); | |
const {JsonRpcProvider} = require("ethers/providers"); | |
function createJsonRpcRequest(method, params) { | |
return { | |
id: nextId++, | |
jsonrpc: "2.0", | |
method, | |
params | |
}; |
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
usePlugin("@nomiclabs/buidler-web3"); | |
task("balance", "Prints an account's balance") | |
.addParam("account", "The account's address") | |
.setAction(async taskArgs => { | |
const account = web3.utils.toChecksumAddress(taskArgs.account); | |
const balance = await web3.eth.getBalance(account); | |
console.log(web3.utils.fromWei(balance, "ether"), "ETH"); | |
}); |
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
usePlugin("@nomiclabs/buidler-web3"); | |
task("balance", "Prints an account's balance"); | |
module.exports = {}; |
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
usePlugin("@nomiclabs/buidler-web3"); | |
task("balance", "Prints an account's balance") | |
.addParam("account", "The account's address") | |
module.exports = {}; |
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
extendEnvironment((env) => { | |
env.hi = "hello, buidler"; | |
}); | |
module.exports = {}; |
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
extendEnvironment((env) => { | |
env.hi = "hello, buidler"; | |
}); | |
task("envtest", (args, env) => { | |
console.log(env.hi); | |
}); | |
module.exports = {}; |
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
extendEnvironment((env) => { | |
const wrapper = new EthersProviderWrapper(env.ethereum); | |
env.ethers = { | |
provider: wrapper, | |
getContract: async function (name) { | |
const artifact = await readArtifact(env.config.paths.artifacts, name); | |
const bytecode = artifact.bytecode; | |
const signers = await env.ethers.signers(); |
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
require("@nomiclabs/buidler-truffle5"); | |
module.exports = { | |
solc: {version: "0.5.2"} | |
}; |
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
const assert = require("assert"); | |
describe("Ethereum provider", function() { | |
it("Should return the accounts", async function() { | |
const accounts = await ethereum.send("eth_accounts"); | |
assert(accounts.length !== 0, "No account was returned"); | |
}); | |
}); | |
contract("Greeter", function() { |
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
async function main() { | |
const Greeter = artifacts.require("Greeter"); | |
const greeter = await Greeter.new("Hello, Buidler!"); | |
console.log("Greeter deployed to:", greeter.address); | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch(error => { |
OlderNewer