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

Registering a namespace

Register your own namespace.

Background Information

Namespaces allow you to create an on-chain unique place for your business and your assets on the Sirius Chain.

A namespace starts with a name that you choose, similar to an internet domain name. If one account creates a namespace, that will appear as unique in the network.

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

Prerequisites

  • Finish the getting started section.
  • XPX-Chain-SDK or XPX-Chain-CLI.
  • A text editor or IDE.
  • An account with XPX.

Getting into some code

  1. Choose a name you like. One common option is to use your company’s or own name. In this example, we will register a namespace called foo.
  2. Check if this namespace name is available.
Golang
TypeScript
JavaScript
Java
CLI
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)

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

namespaceInfo, err := client.Namespace.GetNamespaceInfo(context.Background(), namespaceId)
if err != nil {
panic(err)
}
const namespaceHttp = new NamespaceHttp('http://localhost:3000');

const namespace = new NamespaceId('foo');

namespaceHttp
.getNamespace(namespace)
.subscribe(namespace => console.log(namespace), err => console.error(err));
const namespaceHttp = new NamespaceHttp('http://localhost:3000');

const namespace = new NamespaceId('foo');

namespaceHttp
.getNamespace(namespace)
.subscribe(namespace => console.log(namespace), err => console.error(err));
final NamespaceId namespaceId = new NamespaceId("foo");

final NamespaceHttp namespaceHttp = new NamespaceHttp("http://localhost:3000");

final NamespaceInfo namespaceInfo = namespaceHttp.getNamespace(namespaceId).toFuture().get();

System.out.println(namespaceInfo);
xpx2-cli namespace info --name foo
  1. Is the namespace available? Try to register it before someone else does it! Announce a register namespace transaction with the chosen name and renting duration expressed in blocks.

Note:

In Sirius Chain, blocks are complete every 15 seconds in average. You will have to renew your namespace before it expires.

Golang
TypeScript
JavaScript
Java
// Create an account from a private key
account, err := client.NewAccountFromPrivateKey(os.Getenv("PRIVATE_KEY"))
if err != nil {
panic(err)
}

// Create a new namespace type transaction
transaction, err := client.NewRegisterRootNamespaceTransaction(
// The maximum amount of time to include the transaction in the blockchain.
sdk.NewDeadline(time.Hour),
// Name of namespace
"foo",
// Duration of namespace life in blocks
sdk.Duration(1000),
)
if err != nil {
panic(err)
}

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

// Announce transaction
_, err = client.Transaction.Announce(context.Background(), signedTransaction)
if err != nil {
panic(err)
}
const transactionHttp = new TransactionHttp('http://localhost:3000');

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

const namespaceName = "foo"; //Replace with an unique namespace name

const registerNamespaceTransaction = RegisterNamespaceTransaction.createRootNamespace(
Deadline.create(),
namespaceName,
UInt64.fromUint(1000),
NetworkType.TEST_NET);

const signedTransaction = account.sign(registerNamespaceTransaction, generationHash);

transactionHttp
.announce(signedTransaction)
.subscribe(x => console.log(x), err => console.error(err));
const transactionHttp = new TransactionHttp('http://localhost:3000');

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

const namespaceName = "foo"; //Replace with an unique namespace name

const registerNamespaceTransaction = RegisterNamespaceTransaction.createRootNamespace(
Deadline.create(),
namespaceName,
UInt64.fromUint(1000),
NetworkType.TEST_NET);

const signedTransaction = account.sign(registerNamespaceTransaction, generationHash);

transactionHttp
.announce(signedTransaction)
.subscribe(x => console.log(x), err => console.error(err));
    // Replace with private key
final String privateKey = "<privateKey>";

final Account account = Account.createFromPrivateKey(privateKey, NetworkType.TEST_NET);

// Replace with namespace name
final String namespaceName = "foo";

final RegisterNamespaceTransaction registerNamespaceTransaction = new TransactionBuilderFactory()
.registerNamespace().rootNamespace(namespaceName)
.duration(BigInteger.valueOf(1000))
.deadline(new Deadline(2, ChronoUnit.HOURS))
.networkType(NetworkType.TEST_NET).build();

final SignedTransaction signedTransaction = account.sign(registerNamespaceTransaction, generationHash);

final TransactionHttp transactionHttp = new TransactionHttp("http://localhost:3000");

transactionHttp.announce(signedTransaction).toFuture().get();

What’s next?

When the transaction is confirmed, register a subnamespace following the next guide.

← Sending a multisig transactionRegistering a subnamespace →
  • Background Information
  • 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