Skip to content

Instantly share code, notes, and snippets.

@stonecoldpat
Created Aug 24, 2021
Embed
What would you like to do?
A simple script to show how deploying a contract works.
import { sendTransaction, waitTransaction } from "../utils/itx";
import { setup } from "../utils/utils";
import { PerformanceTestFactory } from "../../out/PerformanceTestFactory";
import { BigNumber, formatEther } from "ethers/utils";
import { AddressZero } from "ethers/constants";
interface Balance {
balance: BigNumber;
}
(async () => {
const { wallet, provider } = await setup();
const bal: Balance = await provider.send("relay_getBalance", [
wallet.address,
]);
console.log("Balance: " + formatEther(bal.balance));
const bytecode = new PerformanceTestFactory(wallet).bytecode;
const relayHash = await sendTransaction(
{
to: AddressZero,
gas: "200002",
data: bytecode,
chainId: 4,
schedule: "fast",
},
wallet,
provider
);
const ethReceipt = await waitTransaction(relayHash, provider);
console.log("Contract address: " + ethReceipt.contractAddress!);
})().catch((e) => {
console.log(e);
// Deal with the fact the chain failed
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment