@rave-names/rave
v3.0.0
Published
Utilities for Rave Names
Downloads
91
Maintainers
Readme
Integrate Rave Names to it's fullest potential in your apps!
rave.js is under development and is subject to change!
Installation
npm i @rave-names/rave
# or with yarn
yarn install @rave-names/raveGetting Started
You're almost there! All you need to do now is create a Rave instance!
import { Rave } from '@rave-names/rave';
const rave = new Rave();This will initialize a Fantom mainnet instance of Rave using rpc.ftm.tools. To customize this, you can initialize rave like this:
import { Rave } from '@rave-names/rave';
import { providers } from 'ethers';
const YOUR_PROVIDER = new providers.JsonRpcProvider('RPC_URL'); //JSON-RPC provider
const YOUR_RAVE_ADDRESS = "0x0000000000000000000000000000000000000000"; //Rave Names contract address
const YOUR_TEXT_RECORD_REGISTRY = "0x0000000000000000000000000000000000000001"; // Custom text registry
const rave = new Rave(YOUR_RAVE_ADDRESS,YOUR_PROVIDER,YOUR_TEXT_RECORD_REGISTRY);The RaveName type
The RaveName type is used globally across rave.js, and represents a name with its attributes.
type RaveName = {
name: string;
isOwned: boolean;
owner?: string;
avatar?: string;
addresses?: object;
};Default address
The default address is 0x98FEF8Da2e27984092B00D8d351b1e625B7E0492, this address is returned as a placeholder, if it is returned, consider it the 0 address
Write Transactions
Some functions are write transactions and require a Signer to execute them.
Functions
What rave.js can do!
resolveNameToAddress(name)
Gets the address that owns name.
Input:
name: RaveName type- The RaveName object that you want to query the name of.
Output:
address: string- Resolved address. If
addressis 0x0000000000000000000000000000000000000000, that means the name isn't owned.
- Resolved address. If
resolveStringToAddress(name)
Gets the address that owns name.
Input:
name: string- Target name
Output:
owner: string- Owner of the name.
reverse(address)
Reverse searches the address to get a fully-populated RaveName object.
Input:
address: string- Target address
index: number- Index of name to look for
Output:
ravename: RaveNameMatching records from input
name: string- The name owned by
address
- The name owned by
isOwned: booleanowner: string- The address passed, or null if the name is unowned
avatar: sting- The avatar link for the name
addresses: string- Multichain addresses
reverseToName(address, index)
Reverse searches the address to get only the name (not the avatar, etc.)
Input:
address: stringindex: number
Output:
name: string
restart(options)
Allows you to modify the provider and address for the contract.
type RestartOptions = {
provider?: any;
address?: any;
}Input:
options: RestartOptionsprovider: any- The new provider
address: any- The new contract address
getPrice()
Gets the price in parsed ether to register 1 Rave Name.
Output:
pricenumber- The price of 1 Rave Name.
owns()
Check if an address owns a Rave Name.
Input:
addressstring- The address
Output:
ownsboolean- If the address owns a name.
getText()
Get the external registry value assigned to a name.
Input:
namestring- The name to lookup
keystring- The key of the record you want to find
Output:
recordstring | null- The record
getTexts()
Get the external registry values assigned to a name.
Input:
namestring- The name to lookup
Output:
recordsRecord[]- The records
isOwned()
Check if an address owns a Rave Name.
Input:
namestring
Output:
ownedboolean- If the name is owned.
The utilities
Contracts
An object of the official Rave Names contract address for chains.
const contracts = {
250: ["0x6A403FFbBF8545EE0d99a63A72e5f335dFCaE2Bd", 'https://rpc.ftm.tools'],
"0xFA": ["0x6A403FFbBF8545EE0d99a63A72e5f335dFCaE2Bd", 'https://rpc.ftm.tools'],
"Fantom": ["0x6A403FFbBF8545EE0d99a63A72e5f335dFCaE2Bd", 'https://rpc.ftm.tools'],
"FTM": ["0x6A403FFbBF8545EE0d99a63A72e5f335dFCaE2Bd", 'https://rpc.ftm.tools'],
}exampleName
An example RaveName object for you to play around with.
const exampleName: RaveName = {
name: 'z.ftm',
isOwned: true,
owner: '0x3e522051a9b1958aa1e828ac24afba4a551df37d',
avatar: 'https://cyber.fantoms.art/Opr.png',
addresses: JSON.parse(addys),
}
