createStateChain
@totemsdk/statechain / createStateChain
Function: createStateChain()
createStateChain(
coinId,owner,sePublicKey,leaseProvider,chainProvider?):Promise<StateChain>
Create a new StateChain by locking a coin into the statechain MULTISIG script.
Public API: createStateChain(coinId, owner, sePublicKey, leaseProvider, chainProvider?)
Steps:
- Resolve coin details (address, tokenId, amount) from owner fields or chainProvider.
- Build the STATE(0)-based locking script and compute lockingAddress.
- Build and sign the LOCK TX: moves
coinIdintolockingAddresswith STATE(0) = ownerPkd. Output coinId becomeschain.coinId. - Broadcast the lock TX if
leaseProvider.broadcastis present. - Register the locked coin with the SE via
seClient.registerChain?. - Pre-sign the initial owner's unilateral reclaim TX (owner can exit without SE after
Parameters
coinId
string
The input UTXO coinId to be locked into the statechain.
chain.coinId will be the LOCK TX output coinId (different).
owner
Initial owner with identity, signing capability, and coin metadata.
owner.address, owner.tokenId, owner.amount must be present
(or derivable from chainProvider).
sePublicKey
string
SE's WOTS public key digest.
leaseProvider
SE client + optional broadcast for the lock TX.
chainProvider?
ChainStateProvider
Optional: fetch coin details when owner metadata is absent.
Returns
Promise<StateChain>
COINAGE
= reclaimTimelock).