Skip to content

Instantly share code, notes, and snippets.

@stonecoldpat
Created August 24, 2021 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stonecoldpat/ac93f436a449ed90d181fc6c3a6f473b to your computer and use it in GitHub Desktop.
Save stonecoldpat/ac93f436a449ed90d181fc6c3a6f473b to your computer and use it in GitHub Desktop.
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