Skip to content

wotori/cw-instantiator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instantiator

The Instantiator contract was developed during the DoraHacks hackathon for Archway Network and the NFText dApp. This contract allows users to instantiate new instances of smart contracts using the already stored .wasm file. The main purpose of this contract is to enable users to instantiate CW721 contracts for their art collections that can be used on NFT platforms.

Workflow

  1. Create the base64 JSON file with data for contract instantiation and pass it as an init_msg parameter.

  2. Build the contract using the archway build --optimize command.

  3. Instantiate the contract using the archway instantiate command, passing in the necessary parameters including the code_id of the stored .wasm file.

  4. Setup metadata for the contract using the archway metadata command.

  5. Check the history of the contract using the archway history command.

  6. Query the contract state using the archway query command.

  7. Execute transactions using the archway tx command, passing in the necessary parameters.

instantiate example: archway instantiate --args '{"minter":"archway1uwew6p8k70xa2lkzeujqcw430uky49zthsvc0y", "name":"test"}'

execute example: archway tx --args '{"instantiate_stored_contract": {"code_id":633, "init_msg": "eyJtaW50ZXIiOiJhcmNod2F5MXFxNjV3amVmdTZubnF4MG42dnZ4NXh6ejN4bWN1eTc1dmF1aHE5IiwgIm5hbWUiOiJ0ZXN0IiwgInN5bWJvbCI6InRlc3QifQ==", "admin": "archway1qq65wjefu6nnqx0n6vvx5xzz3xmcuy75vauhq9", "label":"test"}}'

Instantiate Method

For more information on the Instantiate method, please refer to the following documentation.

JS implementation

let newSmartContractData = {
  minter: walletAddress,
  name: collectionName,
  symbol: collectionSymbol,
};

const base64Str = btoa(JSON.stringify(newSmartContractData));

let instantiateMessage = {
  instantiate_stored_contract: {
    code_id: Number(CW721_CODE_ID),
    admin: walletAddress,
    init_msg: base64Str,
    label: "CW721-USER-COLLECTION",
  },
};

let memo = undefined
let coins = undefined

await client.execute(
  walletAddress,
  contractAddress, // stored instantiator contract
  instantiateMessage,
  calculateFee(600_000, "20uconst"),
  memo,
  coins
)

TODO

In the future, a query method will be added to this contract to collect all executions in the smart contract state and receive all instantiated smart contracts within the Instantiator contract.

About

smart contract for instantiate another smart contracts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages