Documentation Index
Fetch the complete documentation index at: https://initialabs-mintlify-changelog-interwovenkit-1777853576.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Module Addresses
Tutorials
Getting Address from Usernames
To retrieve an address from a username, we use the get_address_from_name
function. The function interface is as follows:
#[view]
public fun get_address_from_name(name: String): Option<address>
const { RESTClient, bcs } = require('@initia/initia.js')
const moduleAddress = '0x...'
const name = 'initia'
const restClient = new RESTClient('https://rest.testnet.initia.xyz', {
gasPrices: '0.015uinit',
gasAdjustment: '1.5',
})
restClient.move
.view(
moduleAddress,
'usernames',
'get_address_from_name',
[],
[bcs.string().serialize(name).toBase64()],
)
.then(console.log)
// Response:
// {
// data: '"0x.."',
// events: [],
// gas_used: '5699'
// }
Getting Usernames from Address
To retrieve a username from an address, we use the get_name_from_address
function.
#[view]
public fun get_name_from_address(addr: address): Option<String>
const { RESTClient, bcs } = require('@initia/initia.js')
const moduleAddress = '0x...'
const address = 'init1...'
const restClient = new RESTClient('https://rest.testnet.initia.xyz', {
gasPrices: '0.015uinit',
gasAdjustment: '1.5',
})
restClient.move
.view(
moduleAddress,
'usernames',
'get_name_from_address',
[],
[bcs.address().serialize(address).toBase64()],
)
.then(console.log)
// Response:
// {
// data: '"abc..."',
// events: [],
// gas_used: '5699'
// }