dispatchSubspaceCreateToChain
dispatchSubspaceCreateToChain(
chainSpace
,creatorUri
,authorAccount
,count
,parent
,signCallback
):Promise
<object
>
Dispatches a Sub-ChainSpace creation transaction to the CORD blockchain.
Parameters
• chainSpace: IChainSpace
The ChainSpace object containing necessary information for creating the ChainSpace on the blockchain.
• creatorUri: did:cord:3${string}
The DID URI of the creator, used to authorize the transaction.
• authorAccount: CordKeyringPair
The blockchain account used for signing and submitting the transaction.
• count: number
• parent: space:cord:${string}
• signCallback: SignExtrinsicCallback
The callback function for signing the transaction.
Returns
Promise
<object
>
A promise resolving to an object containing the ChainSpace URI and authorization ID.
authorization
authorization:
AuthorizationUri
uri
uri:
SpaceUri
Remarks
Responsible for creating a new ChainSpace on the blockchain. It first checks if the ChainSpace with the given URI already exists to avoid duplicates. If not, it constructs and submits a transaction to create the ChainSpace. The transaction requires authorization from the creator and is signed by the specified author account.
Example
const chainSpace: IChainSpace = { // ... initialization of chainSpace properties ...};const creatorUri: DidUri = 'did:cord:creator_uri';const authorAccount: CordKeyringPair = // ... initialization ...const signCallback: SignExtrinsicCallback = // ... implementation ...
try { const result = await dispatchSubspaceCreateToChain(chainSpace, creatorUri, authorAccount, signCallback); console.log('ChainSpace dispatched with URI:', result.uri);} catch (error) { console.error('Error dispatching ChainSpace:', error);}
Throws
- Thrown when there’s an error during the dispatch process.