Run through the full script

This commit is contained in:
Ethan Frey 2020-02-10 16:49:25 +01:00
parent 1bea452fbc
commit ec9a1eab92
2 changed files with 33 additions and 8 deletions

View File

@ -59,7 +59,7 @@ const instantiateContract = async (initClient: RestClient, initPen: Secp256k1Pen
// helper functions
const executeContract = async (execClient: RestClient, execPen: Secp256k1Pen, contractAddr: string, msg: object, transferAmount?: types.Coin[]): Promise<readonly logs.Log[]> => {
const memo = "Create an ERC20 instance";
const sender = encodeAddress({ "type": "tendermint/Secp256k1PubKey", "value": toBase64(execPen.pubkey)}, "cosmos");
const sender = encodeAddress({ "type": types.pubkeyType.secp256k1, "value": toBase64(execPen.pubkey)}, "cosmos");
const instantiateContractMsg = {
type: "wasm/execute",
value: {

View File

@ -1,22 +1,37 @@
## Setup
Start chain:
```sh
./scripts/cosm/start.sh
```
```sh
cd packages/cli
./bin/cosmwasm-cli --init examples/helpers.ts
```
```js
const account = (await client.authAccounts(faucetAddress)).result.value;
account
client.listCodeInfo()
client.listContractAddresses()
```
## Deploy Contract
```sh
node ./scripts/cosm/deploy_erc20.js
```
## Make account
```sh
cd packages/cli
./bin/cosmwasm-cli --init examples/helpers.ts
```
Now, check it and init/execute contracts:
```js
const account = (await client.authAccounts(faucetAddress)).result.value;
account
// see it is now deployed
client.listCodeInfo()
client.listContractAddresses()
@ -34,6 +49,16 @@ const foo = await instantiateContract(client, pen, 1, initMsg);
client.queryContractSmart(foo, { balance: { address: faucetAddress } })
const rcpt = await randomAddress();
rcpt
client.queryContractSmart(foo, { balance: { address: rcpt } })
const execMsg = { transfer: {recipient: rcpt, amount: "808"}}
const exec = await executeContract(client, pen, foo, execMsg);
exec
client.queryContractSmart(foo, { balance: { address: rcpt } })
// TODO: unused account
// TODO: execute and send tokens
```