TypeScript
1
In your project folder, create a minimal package.json
file:
{
"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.radiustech.xyz/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.json
file:
{
"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
Last updated
Was this helpful?