Sirius Chain Developer Center 0.2.6

Sirius Chain Developer Center 0.2.6

  • Getting Started
  • Built-in Features
  • REST API Endpoints
  • Guides
  • Cheat Sheet

›Namespace

Account

  • Creating and opening an account
  • Getting account information
  • Getting the amount of XPX sent to an account
  • Reading transactions from an account

Account Restriction

  • Preventing spam attacks with account restrictions

Aggregate Transaction

  • Sending payouts with aggregate-complete transaction
  • Creating an escrow with aggregate bonded transaction
  • Asking for mosaics with aggregate-bonded transaction
  • Signing announced aggregate-bonded transactions

Block

  • Listening New Blocks
  • Getting block by height

Cross Chain Swaps

  • Atomic cross-chain swap between Sirius public and private chains

Metadata

  • Account Metadata
  • Mosaic Metadata
  • Namespace Metadata

Monitoring

  • Monitor transaction

Mosaic

  • Creating a mosaic
  • Getting the mosaic information
  • Getting the asset identifier behind a namespace with receipts
  • Modifying Mosaic Supply

Multisig Account

  • Converting an account to multisig
  • Modifying a multisig account
  • Creating a multi-level multisig-account
  • Sending a multisig transaction

Namespace

  • Registering a namespace
  • Registering a subnamespace
  • Getting the Namespace information
  • Linking a namespace to a mosaic
  • Linking namespace to account

Transfer Transaction

  • Transfer transaction
  • Sending an encrypted message

Linking a namespace to a mosaic

Link a namespace to a mosaic .

Prerequisites

  • XPX-Chain-SDK or XPX-Chain-CLI
  • A text editor or IDE
  • Have registered one namespace
  • Have registered one mosaic
  • Have one account with xpx

Getting into some code

An account can link a registered name (namespace or subnamespace) with a mosaic.

  1. Define the namespaceId and the address you want to link.
Golang
TypeScript
JavaScript
conf, err := sdk.NewConfig(context.Background(), []string{"http://localhost:3000"})
if err != nil {
panic(err)
}

// Use the default http client
client := sdk.NewClient(nil, conf)

account, err := client.NewAccountFromPrivateKey(os.Getenv("PRIVATE_KEY"))
if err != nil {
panic(err)
}

mosaicId, err := sdk.NewMosaicIdFromNonceAndOwner(nonce, account.PublicAccount.PublicKey)
if err != nil {
panic(err)
}

namespace, _ := sdk.NewNamespaceIdFromName("foo")
if err != nil {
panic(err)
}

transaction, err := client.NewMosaicAliasTransaction(
sdk.NewDeadline(time.Hour),
mosaicId,
namespace,
sdk.AliasLink,
)

if err != nil {
panic(err)
}
const namespaceId = new NamespaceId('foo');
const mosaicId = new MosaicId('7cdf3b117a3c40cc');

const mosaicAliasTransaction = AliasTransaction.createForMosaic(
Deadline.create(),
AliasActionType.Link,
namespaceId,
mosaicId,
NetworkType.TEST_NET
);

const privateKey = process.env.PRIVATE_KEY as string;
const account = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);
const networkGenerationHash = process.env.NETWORK_GENERATION_HASH as string;

const signedTransaction = account.sign(mosaicAliasTransaction, networkGenerationHash);

const namespaceId = new NamespaceId('foo');
const mosaicId = new MosaicId('7cdf3b117a3c40cc');

const mosaicAliasTransaction = AliasTransaction.createForMosaic(
Deadline.create(),
AliasActionType.Link,
namespaceId,
mosaicId,
NetworkType.TEST_NET
);

const privateKey = process.env.PRIVATE_KEY;
const account = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);
const networkGenerationHash = process.env.NETWORK_GENERATION_HASH;

const signedTransaction = account.sign(mosaicAliasTransaction, networkGenerationHash);

  1. Announce the alias transaction.
Golang
TypeScript
JavaScript

signedTransaction, err := account.Sign(transaction)
if err != nil {
panic(err)
}

_, err = client.Transaction.Announce(context.Background(), signedTransaction)
if err != nil {
panic(err)
}

const transactionHttp = new TransactionHttp('http://localhost:3000');

transactionHttp
.announce(signedTransaction)
.subscribe(x => console.log(x), err => console.error(err));

const transactionHttp = new TransactionHttp('http://localhost:3000');

transactionHttp
.announce(signedTransaction)
.subscribe(x => console.log(x), err => console.error(err));

If you want to unlink the alias, change alias action type to AliasActionType.Unlink.

What’s next?

Now you can send transactions using the namespace linked to the mosaic instead of defining the complete mosaicId.

← Getting the Namespace informationLinking namespace to account →
  • Prerequisites
  • Getting into some code
  • What’s next?
  • Join #general discussion
  • Ask development questions
  • Follow the dev updates
  • Explore Github
Protocol
BlockConsensus AlgorithmsCryptographyInflationNodeReceiptTransactionValidating
Built-in Features
AccountAccount FilterAggregate TransactionCross-Chain SwapsExchange MarketMetadataMosaicMultisig AccountNamespaceSuper contractTransfer Transaction
References
REST APISDKsXPX-Chain-CLICheat Sheet
Documentation Forked From NEM
Copyright © 2020 ProximaX