Skip to main content

Accounts

Learn how to create and manage accounts on GLIN Network.

Overview

Accounts on GLIN Network are cryptographic key pairs that allow you to:

  • 🔐 Sign transactions - Prove ownership of assets
  • 💰 Hold balances - Store GLIN tokens
  • 📝 Deploy contracts - Create smart contracts
  • 🔑 Control identities - Manage on-chain identity

Account Types

Development Accounts

Pre-funded accounts for testing (NEVER use in production):

import { Keyring } from '@glin-ai/sdk';

const keyring = new Keyring({ type: 'sr25519' });

// Well-known development accounts
const alice = keyring.addFromUri('//Alice');
const bob = keyring.addFromUri('//Bob');
const charlie = keyring.addFromUri('//Charlie');
const dave = keyring.addFromUri('//Dave');
const eve = keyring.addFromUri('//Eve');

console.log('Alice:', alice.address);
console.log('Bob:', bob.address);

Production Accounts

Securely generated accounts for real use:

import { Keyring } from '@glin-ai/sdk';
import { mnemonicGenerate } from '@polkadot/util-crypto';

// Generate new mnemonic
const mnemonic = mnemonicGenerate(12);
console.log('Mnemonic:', mnemonic);
// Save this securely!

// Create account from mnemonic
const keyring = new Keyring({ type: 'sr25519' });
const account = keyring.addFromMnemonic(mnemonic);

console.log('Address:', account.address);
console.log('Public key:', account.publicKey);

Create Accounts

From Seed Phrase

import { Keyring } from '@glin-ai/sdk';

const keyring = new Keyring({ type: 'sr25519' });

// From 12-word mnemonic
const account = keyring.addFromMnemonic(
'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
);

console.log('Address:', account.address);

From Private Key

import { Keyring } from '@glin-ai/sdk';

const keyring = new Keyring({ type: 'sr25519' });

// From hex private key
const account = keyring.addFromUri('0x1234567890abcdef...');

console.log('Address:', account.address);

Check Balance

import { GlinClient } from '@glin-ai/sdk';

const client = await GlinClient.connect('wss://testnet.glin.ai');

const balance = await client.getBalance(account.address);

console.log('Free:', balance.free.toString());
console.log('Reserved:', balance.reserved.toString());
console.log('Frozen:', balance.frozen.toString());

Transfer Funds

// Transfer 10 GLIN
const amount = 10n * 10n ** 18n;

const transfer = client.api.tx.balances.transfer(
recipientAddress,
amount
);

const hash = await transfer.signAndSend(sender);
console.log('Transaction hash:', hash.toHex());

Account Security

⚠️ Development Accounts

NEVER use in production:

  • //Alice, //Bob, etc. are publicly known
  • Private keys are hardcoded in many tools
  • Anyone can access funds from these accounts

✅ Production Best Practices

  1. Generate Secure Mnemonics

    const mnemonic = mnemonicGenerate(12); // or 24 words
  2. Store Mnemonics Securely

    • Use hardware wallets (Ledger, Trezor)
    • Encrypted password managers
    • Never commit to git or share online
  3. Use Environment Variables

    const mnemonic = process.env.WALLET_MNEMONIC;
    if (!mnemonic) throw new Error('WALLET_MNEMONIC not set');
  4. Separate Accounts by Purpose

    • Hot wallet: Small amounts for daily use
    • Cold wallet: Large amounts for storage
    • Contract deployment: Separate from funds

Account Derivation

Create multiple accounts from one seed:

const keyring = new Keyring({ type: 'sr25519' });

// Derive child accounts
const account0 = keyring.addFromUri(`${mnemonic}//0`);
const account1 = keyring.addFromUri(`${mnemonic}//1`);
const account2 = keyring.addFromUri(`${mnemonic}//2`);

console.log('Account 0:', account0.address);
console.log('Account 1:', account1.address);
console.log('Account 2:', account2.address);

Multi-Signature Accounts

Create accounts controlled by multiple parties:

import { encodeMultiAddress } from '@polkadot/util-crypto';

// Create multisig with 2-of-3 threshold
const signatories = [
alice.address,
bob.address,
charlie.address
];

const threshold = 2;

const multisigAddress = encodeMultiAddress(signatories, threshold);
console.log('Multisig address:', multisigAddress);

// Send funds to multisig
const transfer = client.api.tx.balances.transfer(multisigAddress, amount);
await transfer.signAndSend(alice);

// Execute from multisig (requires 2 signatures)
const call = client.api.tx.balances.transfer(recipient, amount);

// First approval
const approveAsMulti1 = client.api.tx.multisig.approveAsMulti(
threshold,
signatories.filter(s => s !== alice.address),
null,
call.method.hash,
0
);
await approveAsMulti1.signAndSend(alice);

// Second approval + execution
const asMulti = client.api.tx.multisig.asMulti(
threshold,
signatories.filter(s => s !== bob.address),
null,
call.method,
0
);
await asMulti.signAndSend(bob);

Proxy Accounts

Delegate permissions to other accounts:

// Add proxy
const addProxy = client.api.tx.proxy.addProxy(
proxyAddress,
'Any', // Proxy type: Any, NonTransfer, Governance, etc.
0 // Delay in blocks
);

await addProxy.signAndSend(mainAccount);

// Execute via proxy
const call = client.api.tx.balances.transfer(recipient, amount);

const proxy = client.api.tx.proxy.proxy(
mainAccount.address,
null, // Force proxy type
call
);

await proxy.signAndSend(proxyAccount);

Next Steps


Need help? Join our Discord