Create Proposal

Creating Proposal

On creating proposal, client need to direct the execution call to "Vote contract" as the target contract address.

const executionResponse = await client?.execute(userAddress, voteAddress, proposalPayload, 'auto');

Proposal Payload

The proposal payload will have "propose" as Json key and the json child will have 4 keys which are:

  • title (required)

  • description (required)

  • msgs (required): array of CosmosMsg json object

  • latest <optional>: to set expiration

const payload = {
    propose : {
      title,
      description,
      msgs: [
        cosmosWasmMsg,
      ],
    }
}

The CosmosMsg that client should pass as message is the json representation of WasmMsg::Execute. The reason is we need to forward call/exeuction to other contract which is instance of cw-ica-controller contract that will forward the call to be executed by ICA address in the target chain.

const cosmosWasmMsg = {
          wasm: {
            execute: {
              contract_addr: icaControllerAddress,
              msg: Buffer.from(JSON.stringify(controllerMessage)).toString('base64'),
              funds: [],
            },
          },
  };

The WasmMsg::Execute json payload above will be executed by controllerAddress and the message inside it should have "send_cosmos_msgs" json key like below:

 const controllerMessage = {
    send_cosmos_msgs: {
      messages: [
        {
          stargate: {
            type_url: msg.typeUrl,
            value: Buffer.from(encodedMsg).toString('base64'),
          },
        },
      ],
      packet_memo: 'packet memo by nomos',
    },
  };

The content of messages array should be Stargate message that always have two json keys which are:

  • type_url

  • value

A Stargate message encoded the same way as a protobuf Any. This is the same structure as messages in TxBody from ADR-020

Last updated