cosmjs-util/scripts/wasmd/deploy_erc20.js
Simon Warta cd40206651 Use new token names HASH/ISA/JADE
those don't conflict with other BCP demo tokens
2020-02-18 17:55:46 +01:00

84 lines
2.1 KiB
JavaScript
Executable File

#!/usr/bin/env node
/* eslint-disable @typescript-eslint/camelcase */
const { SigningCosmWasmClient, Secp256k1Pen } = require("@cosmwasm/sdk");
const fs = require("fs");
const httpUrl = "http://localhost:1317";
const faucet = {
mnemonic:
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
};
const unused = {
address: "cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u",
};
const initMsgHash = {
decimals: 5,
name: "Hash token",
symbol: "HASH",
initial_balances: [
{
address: faucet.address,
amount: "11",
},
{
address: unused.address,
amount: "12812345",
},
],
};
const initMsgIsa = {
decimals: 0,
name: "Isa Token",
symbol: "ISA",
initial_balances: [
{
address: faucet.address,
amount: "999999999",
},
{
address: unused.address,
amount: "42",
},
],
};
const initMsgJade = {
decimals: 18,
name: "Jade Token",
symbol: "JADE",
initial_balances: [
{
address: faucet.address,
amount: "189189189000000000000000000", // 189189189 JADE
},
],
};
async function main() {
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const wasm = fs.readFileSync(__dirname + "/contracts/cw-erc20.wasm");
const codeId = await client.upload(wasm, "Upload ERC20 contract");
console.info(`Upload succeeded. Code ID is ${codeId}`);
for (const initMsg of [initMsgHash, initMsgIsa, initMsgJade]) {
const memo = `Create an ERC20 instance for ${initMsg.symbol}`;
const contractAddress = await client.instantiate(codeId, initMsg, memo);
console.info(`Contract instantiated for ${initMsg.symbol} at ${contractAddress}`);
}
}
main().then(
() => {
console.info("All done, let the coins flow.");
process.exit(0);
},
error => {
console.error(error);
process.exit(1);
},
);