Skip to main content

Import Token

Example

To import your token that was minted on the L1 outside of a verse, you must call importMintedToken on dataset(Dataset.TOKEN). importMintedToken takes an object of type Build5Request<ImportMintedTokenRequest> as parameter.

    const response = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.TOKEN)
.importMintedToken({
address: address.bech32,
signature: signature.signature,
publicKey: {
hex: signature.publicKey,
network: Network.RMS,
},
body: {
network: 'rms',
space: 'Nordpol',
tokenId: 'tokenId',
},
});

importMintedToken returns an oject of type Transaction.

Full How-To Code

import { Dataset, Network } from '@build-5/interfaces';
import { Build5, SoonaverseApiKey, https } from '@build-5/sdk';
import { address } from '../../utils/secret';
import { walletSign } from '../../utils/utils';

async function main() {
const origin = Build5.TEST;

try {
const member = await https(origin)
.project(SoonaverseApiKey[Build5.TEST])
.dataset(Dataset.MEMBER)
.id(address.bech32)
.get();

const signature = await walletSign(member.uid, address);
const response = await https(origin)
.project(SoonaverseApiKey[origin])
.dataset(Dataset.TOKEN)
.importMintedToken({
address: address.bech32,
signature: signature.signature,
publicKey: {
hex: signature.publicKey,
network: Network.RMS,
},
body: {
network: 'rms',
space: 'Nordpol',
tokenId: 'tokenId',
},
});

console.log(response);
} catch (e) {
console.log(e);
return;
}
}

main().then(() => process.exit());