Skip to content

Instantly share code, notes, and snippets.

View fzeoli's full-sized avatar
💭
Try Buidler! https://buidler.dev

Franco Zeoli fzeoli

💭
Try Buidler! https://buidler.dev
View GitHub Profile
const { ContractFactory, ethers, Signer } = require("ethers");
const {JsonRpcProvider} = require("ethers/providers");
function createJsonRpcRequest(method, params) {
return {
id: nextId++,
jsonrpc: "2.0",
method,
params
};
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");
});
usePlugin("@nomiclabs/buidler-web3");
task("balance", "Prints an account's balance");
module.exports = {};
usePlugin("@nomiclabs/buidler-web3");
task("balance", "Prints an account's balance")
.addParam("account", "The account's address")
module.exports = {};
extendEnvironment((env) => {
env.hi = "hello, buidler";
});
module.exports = {};
extendEnvironment((env) => {
env.hi = "hello, buidler";
});
task("envtest", (args, env) => {
console.log(env.hi);
});
module.exports = {};
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();
require("@nomiclabs/buidler-truffle5");
module.exports = {
solc: {version: "0.5.2"}
};
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() {
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 => {