-
-
Save stonecoldpat/ac93f436a449ed90d181fc6c3a6f473b to your computer and use it in GitHub Desktop.
A simple script to show how deploying a contract works.
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
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