Blueprint
A BlueprintPromise
wraps an existing codeHash
and an Abi
and provides the opportunity to create contracts on-chain. It is either created via new BlueprintPromise
from an existing codeHash
, or as seen in the code example from deploying a WASM code bundle on-chain.
Assuming that we did not deploy code, we can start by creating one (if following from the previous section, this is for information only, since you already have access to the created Blueprint from CodePromise
) -
As with the CodePromise
sample, we require an ApiPromise
, Abi
and the actual codeHash
, as found on-chain. If a non-existent codeHash
is used, it will fail on actual contract creation, which is the next step.
#
Create a contractWe either have a Blueprint
from a code deploy of a manual create. From here we can create an actual contract instance. For this example, we are assuming a normal incrementer contract to allow us have a known example to show the actual use -
As per the Code
examples previously, the tx.<constructorName>
interface is a normal submittable extrinsic with the result containing an actual ContractPromise
instance as created with the address from the events from deployment. Internally it will use the instantiate
extrinsic and interpret the events retrieved.
For cases where we want to refer to the message via index (or actual Abi message), we can use the .createContract
helper on the Blueprint
, in this case the lower-level code would yield -
#
Interact with contractsWe have made it this far. At this point you should be familiar with code deployments as well as contract instantiation, next up we will read a contract.