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.
-
Create the base64 JSON file with data for contract instantiation and pass it as an
init_msgparameter. -
Build the contract using the
archway build --optimizecommand. -
Instantiate the contract using the
archway instantiatecommand, passing in the necessary parameters including thecode_idof the stored .wasm file. -
Setup metadata for the contract using the
archway metadatacommand. -
Check the history of the contract using the
archway historycommand. -
Query the contract state using the
archway querycommand. -
Execute transactions using the
archway txcommand, 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"}}'
For more information on the Instantiate method, please refer to the following documentation.
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
)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.