Skip to content

Commit

Permalink
Update tokens.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ltfschoen authored Apr 26, 2024
1 parent 3307a2f commit 5ec8096
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions docs/build/sdk/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ this is the full sample code that creates a new collection and a new token in it
<CodeGroupItem title = "SDK">

```ts:no-line-numbers
import {Sdk} from '@unique-nft/sdk'
import Sdk, {CHAIN_CONFIG} from '@unique-nft/sdk'
import {KeyringProvider} from '@unique-nft/accounts/keyring'
async function main() {
const account = await KeyringProvider.fromMnemonic(
'bonus rubber price teach teach teach teach century scorpion require require require'
)
const address = account.getAddress()
const address = account.address
const sdk = new Sdk({
baseUrl: 'https://rest.unique.network/opal/v1',
baseUrl: CHAIN_CONFIG.opal.restUrl,
signer: account,
})
////////////////////////////////////
// Create collection - quick simple way
////////////////////////////////////
const {parsed, error} = await sdk.collections.creation.submitWaitResult({
const {parsed, error} = await sdk.collections.create.submitWaitResult({
address,
name: 'Test collection',
description: 'My test collection',
Expand All @@ -90,11 +90,12 @@ async function main() {
}
const collectionId = parsed?.collectionId as number
console.log(`Collection created. Id: ${collectionId}`)
console.log(`View this minted collection at https://uniquescan.io/opal/collections/${collectionId}`)
////////////////////////////////////
// Mint token
////////////////////////////////////
const result = await sdk.tokens.create.submitWaitResult({
const result = await sdk.token.create.submitWaitResult({
address,
collectionId,
data: {
Expand All @@ -112,7 +113,8 @@ async function main() {
const tokenId = result.parsed?.tokenId as number
console.log(`Created token ${tokenId} in collection ${collectionId}`)
console.log(`Minted token ID ${tokenId} of 1 in collection ID ${collectionId}`)
console.log(`View this minted token at https://uniquescan.io/opal/tokens/${collectionId}/${tokenId}`)
}
main().catch((error) => {
Expand Down Expand Up @@ -177,7 +179,7 @@ async function main() {
...
const result = await sdk.tokens.createMultiple.submitWaitResult({
const result = await sdk.token.createMultiple.submitWaitResult({
address,
collectionId,
tokens: [ // array of tokens
Expand All @@ -204,9 +206,14 @@ async function main() {
],
})
const mintedTokens = result.parsed?.length
const mintedTokensCount = result.parsed?.length
console.log(`Minted ${mintedTokens} tokens in collection ${collectionId}`)
let currentTokenId;
result.parsed?.forEach((token, index) => {
currentTokenId = token?.tokenId as number
console.log(`Minted token ID #${currentTokenId}/${mintedTokensCount} in collection ${collectionId}`)
console.log(`View this minted token at https://uniquescan.io/opal/tokens/${collectionId}/${currentTokenId}`)
});
}
```
</CodeGroupItem>
Expand Down Expand Up @@ -647,4 +654,4 @@ curl -X 'POST' \
```

</CodeGroupItem>
</CodeGroup>
</CodeGroup>

0 comments on commit 5ec8096

Please sign in to comment.