9. Wallet interaction
Transferring a state involves several stages.
First, a wallet has to compose a PSBT file defining the structure of an underlying witness transaction.
Based on this PSBT, a list of spent outputs is passed to the RGB Node, given a specific contract id. The Node prepares a state transfer consignment, which contains the whole history for the spent outputs.
This consignment is now used in transfer preparation, when based on the consignment file, PSBT, list of beneficiaries and available change addresses a (bundled) new state transition(s) for the state transfers are composed. This is performed not by an RGB Node but by a software/library, aware of the contract schema and semantics (assets, NFTs etc); i.e usually by a wallet using some schema-specific helper library, like RGB20.
Next, RGB Node is asked to finalize the consignment and prepare a disclosure. It includes the following operations:
Extracting all other contracts affected by the operation; preparing "blank" state transitions for them;
Packing state transitions under the main contract with additional blank transitions under other affected contracts into an anchor;
Updating the consignment with the newly formed anchor and state transition;
Preparing a disclosure, that will contain the remaining blank state transitions. This disclosure will be used later for updating the stash when the witness transaction is mined.
This completes the composition of a new state transfer consignment and corresponding witness transaction. The consignment is sent to the beneficiary, who must return a signature on this transfer. Once the signature is received, the witness transaction from the PSBT should be signed by all signers and published to the network - and RGB Node in parallel should enclose previously prepared disclosure to maintain the state of the remaining smart contracts as valid.
Last updated