Skip to content

Commit

Permalink
setup script for deploying directly to a network
Browse files Browse the repository at this point in the history
  • Loading branch information
pirtleshell committed May 19, 2023
1 parent f512d09 commit f1eaf5a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
10 changes: 10 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ npm run dev
npm run test-watch
```

## Deploying contracts to test networks

A deploy script is included in this hardhat project to deploy a contract directly to a network.
To deploy the contracts to different networks:
```
npx hardhat run --network <network-name> scripts/deploy.ts
```

Configuration for various `<network-name>`s above are setup in the [hardhat config](./hardhat.config.ts).

## Production compiling & Ethermint JSON

Ethermint uses its own json format that includes the ABI and bytecode in a single file. The bytecode should have no `0x` prefix and should be under the property name `bin`. This structure is built from the compiled code with `npm ethermint-json`.
Expand Down
24 changes: 24 additions & 0 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,37 @@ const config: HardhatUserConfig = {
solidity: {
version: "0.8.18",
settings: {
// istanbul upgrade occurred before the london hardfork, so is compatible with kava's evm
evmVersion: "istanbul",
// optimize build for deployment to mainnet!
optimizer: {
enabled: true,
runs: 1000,
},
},
},
networks: {
// kvtool's local network
kava: {
url: "http://127.0.0.1:8545",
accounts: [
// kava keys unsafe-export-eth-key whale2
"AA50F4C6C15190D9E18BF8B14FC09BFBA0E7306331A4F232D10A77C2879E7966",
],
},
protonet: {
url: "https://evm.app.protonet.us-east.production.kava.io:443",
accounts: [
"247069F0BC3A5914CB2FD41E4133BBDAA6DBED9F47A01B9F110B5602C6E4CDD9",
],
},
internal_testnet: {
url: "https://evm.data.internal.testnet.us-east.production.kava.io:443",
accounts: [
"247069F0BC3A5914CB2FD41E4133BBDAA6DBED9F47A01B9F110B5602C6E4CDD9",
],
},
},
};

export default config;
4 changes: 1 addition & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"clean": "hardhat clean",
"compile": "hardhat compile",
"coverage": "hardhat coverage",
"dev": "hardhat watch dev",
"ethermint-json": "jq '{ abi: .abi | tostring, bin: .bytecode | ltrimstr(\"0x\")}' artifacts/contracts/ERC20KavaWrappedNativeCoin.sol/ERC20KavaWrappedNativeCoin.json > ../x/evmutil/types/ethermint_json/ERC20KavaWrappedNativeCoin.json",
"gen-ts-types": "hardhat typechain",
"lint": "eslint '**/*.{js,ts}'",
Expand All @@ -21,8 +20,7 @@
"prettier-fix": "prettier '**/*.{json,sol,md}' --write",
"solhint": "solhint 'contracts/**/*.sol' --max-warnings 0",
"solhint-fix": "solhint 'contracts/**/*.sol' --fix",
"test": "hardhat test",
"test-watch": "hardhat watch test"
"test": "hardhat test"
},
"devDependencies": {
"@nomicfoundation/hardhat-toolbox": "^2.0.2",
Expand Down
27 changes: 27 additions & 0 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ethers } from "hardhat";

async function main() {
const tokenName = "Kava-wrapped ATOM";
const tokenSymbol = "kATOM";
const tokenDecimals = 6;

const ERC20KavaWrappedNativeCoin = await ethers.getContractFactory(
"ERC20KavaWrappedNativeCoin"
);
const token = await ERC20KavaWrappedNativeCoin.deploy(
tokenName,
tokenSymbol,
tokenDecimals
);

await token.deployed();

console.log(
`Token "${tokenName}" (${tokenSymbol}) with ${tokenDecimals} decimals is deployed to ${token.address}!`
);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

0 comments on commit f1eaf5a

Please sign in to comment.