@iota/iota-names-sdk
v0.6.1
Published
IOTA-Names SDK
Readme
IOTA-Names SDK
A TypeScript SDK for interacting with the IOTA Name Service. This SDK provides a convenient wrapper for querying detailed information and building transactions for IOTA-Names.
Note: You do not need to use this SDK for basic name resolution (name → address, address → name). That functionality is already covered by JSONRPC & GraphQL APIs.
Installation
npm install @iota/iota-names-sdkOr with yarn:
yarn add @iota/iota-names-sdkOr with pnpm:
pnpm add @iota/iota-names-sdkRequirements
- Node.js 22+
Basic Usage
Initialize the Client
import { IotaNamesClient } from '@iota/iota-names-sdk';
import { getNetwork, Network } from '@iota/iota-sdk/client';
import { IotaGraphQLClient } from '@iota/iota-sdk/graphql';
// Initialize the SDK client
const network = getNetwork(Network.Mainnet); // or Network.Testnet, Network.Devnet
const iotaNamesClient = new IotaNamesClient({
graphQlClient: new IotaGraphQLClient({
url: network.graphql!,
}),
network: network.id,
});Register a Name
import { IotaNamesTransaction } from '@iota/iota-names-sdk';
import { Transaction } from '@iota/iota-sdk/transactions';
// Create a transaction to register a name
const tx = new Transaction();
const iotaNamesTx = new IotaNamesTransaction(iotaNamesClient, tx);
const [coin] = iotaNamesTx.transaction.splitCoins(tx.gas, [10_000_000]);
// Register the name
const nft = await iotaNamesTx.register({
name: 'mycoolname.iota',
coin,
});
// Transfer the NFT to your address
iotaNamesTx.transaction.transferObjects([nft], address);
//Build transaction
const transaction = await iotaNamesTx.transaction.build({
client,
});Query Name Information
// Get name record
const nameRecord = await iotaNamesClient.getNameRecord('example.iota');
console.log(nameRecord);
// Get price lists
const priceList = await iotaNamesClient.getPriceList();
const renewalPriceList = await iotaNamesClient.getRenewalPriceList();Features
- Name registration and management
- Price querying
- Setting and updating name metadata
- Subname management
- Support for coupons and discounts
- Handling name expiration and renewals
Examples
The SDK includes several examples that demonstrate common use cases:
- Basic name registration
- Setting name record data
- Using coupons
- Command center operations
- Working with subnames
For detailed examples, check the examples directory in the repository.
API Reference
For complete API documentation, visit the IOTA-Names Documentation.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For more information about IOTA-Names, visit the official documentation.
