Skip to content

Instantly share code, notes, and snippets.

@suraneti
Created May 25, 2022 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suraneti/58ae759d00b92781ccba82f88cc77f63 to your computer and use it in GitHub Desktop.
Save suraneti/58ae759d00b92781ccba82f88cc77f63 to your computer and use it in GitHub Desktop.
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
(async () => {
const sleep = ms => new Promise(r => setTimeout(r, ms));
try {
const artifactsPath = `browser/contracts/artifacts/Storage.json` // Change this for different path
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
const signer = new ethers.Wallet("<PRIVATE_KEY>", new ethers.providers.Web3Provider(web3Provider));
let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer);
console.log(`deploying contract...`)
contract = await factory.deploy();
await contract.deployed()
console.log(`ca: ${contract.address}`)
// load existing contract
// const contract = new ethers.Contract("<CONTRACT_ADDRESS>", metadata.abi, signer)
for (let i = 1; i <= 10; i++) {
console.log(`store loops: ${i}`)
await sleep(30000)
contract.store(i).then((tx) => (console.log(`tx ${i}`, tx))).catch(console.log)
}
} catch (e) {
console.log(e)
}
})()
@suraneti
Copy link
Author

suraneti commented May 25, 2022

Screen Shot 2565-05-25 at 09 24 51

I recommend creating a new wallet to do this.

  1. Create a new script file with this source code.
  2. Replace "<PRIVATE_KEY>" with your private key, *DO WITH YOUR OWN RISK
  3. Right-click to run a script and wait until the loop finish takes about 5 mins.

@suraneti
Copy link
Author

Kilin testnet faucet
https://kilnfaucet.com/

Kilin RPC
https://rpc.kiln.themerge.dev

Kilin testnet resources
https://kiln.themerge.dev/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment