JavaScript

1

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

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

Install the Radius TypeScript SDK:

npm i @radiustechsystems/sdk
3

Create a TypeScript file called 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.

const {
  AddressFromHex,
  NewClient,
  NewAccount,
  withPrivateKey,
} = require('@radiustechsystems/sdk');

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

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

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

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

Compile and run the code using the following command:

node index.js

Last updated

Was this helpful?