LogoLogo
  • Introduction
  • Radius testnet access
  • Quickstart
    • Command line
    • Go
    • JavaScript
    • Postman
    • Python
    • Rust
    • TypeScript
  • How to
    • Create a Private Key
    • Get testnet ETH tokens
    • Deploy a smart contract
  • Concepts
    • Ethereum transaction types
  • Tutorials
  • Radius SDKs
  • API Reference
    • eth_blockNumber
    • eth_call
    • eth_chainId
    • eth_createAccessList
    • eth_estimateGas
    • eth_feeHistory
    • eth_gasPrice
    • eth_getBalance
    • eth_getBlock
    • eth_getBlockByHash
    • eth_getBlockByNumber
    • eth_getBlockTransactionCountByHash
    • eth_getBlockTransactionCountByNumber
    • eth_getCode
    • eth_getLogs
    • eth_getStorageAt
    • eth_getTransactionByBlockHashAndIndex
    • eth_getTransactionByBlockNumberAndIndex
    • eth_getTransactionByHash
    • eth_getTransactionCount
    • eth_getTransactionReceipt
    • eth_sendRawTransaction
    • eth_sendTransaction
    • net_version
    • web3_clientVersion
    • web3_sha3
    • web3_getTransactionCount
  • Release Notes
  • Whitepaper
  • Radius Discord
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Quickstart

TypeScript

PreviousRustNextHow to

Last updated 2 months ago

Was this helpful?

1

In your project folder, create a minimal package.jsonfile:

{
  "name": "radius-quickstart",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@radiustechsystems/sdk": "^1.0.0"
  }
}
2

Install the Radius TypeScript SDK:

npm i @radiustechsystems/sdk
3

Create a TypeScript file called index.ts:

import {
  Account,
  Address,
  AddressFromHex,
  Client,
  NewClient,
  NewAccount,
  Receipt,
  withPrivateKey,
} from '@radiustechsystems/sdk';

// Replace the following values with your own
const RADIUS_ENDPOINT = "https://rpc.testnet.tryradi.us/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const PRIVATE_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

async function main() {
  const client: Client = await NewClient(RADIUS_ENDPOINT);
  const account: Account = await NewAccount(withPrivateKey(PRIVATE_KEY, client));
  const recipient: Address = AddressFromHex('0x...'); // Replace with recipient address
  const amount: bigint = BigInt(100);
  const receipt: Receipt = await account.send(client, recipient, amount);

  console.log('Transaction hash:', receipt.txHash.hex());
}

main().catch(console.error);
4

Create a minimal tsconfig.jsonfile:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}
5

Compile and run the code using the following command:

tsc && node index.js

Be sure to replace the RADIUS_ENDPOINT and PRIVATE_KEY values with your own. See also: Radius testnet access and Create a Private Key.