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

›Account

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

Creating and opening an account

This guide will help you create a new account and open it.

Prerequisites

  • Finish the getting started section.
  • Text editor or IDE.
  • XPX-Chain-SDK or XPX-Chain-CLI.

Getting into some code

An account is a key pair (private and public key) associated with a mutable state stored in the Sirius Chain.

Golang
TypeScript
JavaScript
Java
CLI
keyPair, _ := crypto.NewRandomKeyPair()

fmt.Printf("PublicKey:\t%x\n", keyPair.PublicKey.Raw)
fmt.Printf("PrivateKey:\t%x", keyPair.PrivateKey.Raw)
const account = Account.generateNewAccount(NetworkType.TEST_NET);

console.log('Address:', account.address.pretty());
console.log('PrivateKey:', account.privateKey);
console.log('PublicKey:', account.publicKey);
const account = Account.generateNewAccount(NetworkType.TEST_NET);

console.log('Address:', account.address.pretty());
console.log('PrivateKey:', account.privateKey);
console.log('PublicKey:', account.publicKey);
final Account account = Account.generateNewAccount(NetworkType.TEST_NET);

System.out.printf("Address: '%S' %n", account.getAddress());
System.out.printf("PrivateKey: '%S' %n", account.getPrivateKey());
System.out.printf("PublicKey: '%S' %n", account.getPublicKey());
xpx2-cli account generate --network TEST_NET

The private key uniquely identifies a Sirius Chain account and holds all of its power. It is a priority to ensure it is stored safely somewhere offline and not to share it with anyone.

The public key is cryptographically derived from the private key and safe to be shared. Nonetheless, it is preferable to share the address, which contains further information such as network and validity check.

If you already have a private key, it is not necessary to generate a new account:

Golang
TypeScript
JavaScript
Java
account, _ := sdk.NewAccountFromPrivateKey("...", sdk.TEST_NET)

fmt.Printf("Address:\t%v\n", account.Address)
fmt.Printf("PrivateKey:\t%x\n", account.KeyPair.PrivateKey.Raw)
fmt.Printf("PublicKey:\t%x", account.KeyPair.PublicKey.Raw)
// Replace with a private key
const privateKey = process.env.PRIVATE_KEY as string;

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

console.log('Address:', account.address.pretty());
console.log('PrivateKey:', account.privateKey);
console.log('PublicKey:', account.publicKey);
// Replace with a private key
const privateKey = process.env.PRIVATE_KEY;

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

console.log('Address:', account.address.pretty());
console.log('PrivateKey:', account.privateKey);
console.log('PublicKey:', account.publicKey);
    // Replace with a private key
final String privateKey = "<private_key>";

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

System.out.printf("Address: '%S' %n", account.getAddress());
System.out.printf("PrivateKey: '%S' %n", account.getPrivateKey());
System.out.printf("PublicKey: '%S' %n", account.getPublicKey());

Using a Wallet

If the programming language of the SDK you are using allows client-side development, you can create a wallet.

A wallet enables you to store your account to sign transactions, encrypting your private key with a password.

TypeScript
JavaScript
const password = new Password('password');

const wallet = SimpleWallet.create('wallet-name', password, NetworkType.TEST_NET);

const account = wallet.open(password);

console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);
const password = new Password('password');

const wallet = SimpleWallet.create('wallet-name', password, NetworkType.TEST_NET);

const account = wallet.open(password);

console.log('Your new account address is:', account.address.pretty(), 'and its private key', account.privateKey);

Do you have a private key? You can create and open a wallet importing your private key.

TypeScript
JavaScript
const password = new Password('password');

// Replace with a private key
const privateKey = process.env.PRIVATE_KEY as string;

const wallet = SimpleWallet.createFromPrivateKey('wallet-name', password, privateKey, NetworkType.TEST_NET);

const account = wallet.open(password);

console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
const password = new Password('password');

// Replace with a private key
const privateKey = process.env.PRIVATE_KEY;

const wallet = SimpleWallet.createFromPrivateKey('wallet-name', password, privateKey, NetworkType.TEST_NET);

const account = wallet.open(password);

console.log('Your account address is:', account.address.pretty(), 'and its private key', account.privateKey);
Getting account information →
  • Prerequisites
  • Getting into some code
    • Using a Wallet
  • 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