@address-book/sdk
v0.1.2
Published
The sdk package provides a simple and efficient way to resolve email addresses into their corresponding Ethereum addresses (0x) using the Address Book protocol. This SDK is designed to integrate seamlessly into decentralized applications (dApps) and block
Downloads
78
Readme
Address Book SDK
The sdk package provides a simple and efficient way to resolve email addresses into their corresponding Ethereum addresses (0x) using the Address Book protocol.
Getting started
Install
npm install @address-book/sdk
Usage
import { resolveByNickname, resolveByAddress, resolveByEmail } from '@address-book/sdk';
const info = await resolveByNickname('0xVinny')
// { info: { address: '0xeeC5915A21DA64a58DE1e9a3D7dd7b8Bff775cF0' avatar: 'base64...', nickname: '0xVinny', freeText: '...' } , resolvedAt: '...', resolvedBy: 'nickname' }
import { resolveByAddress } from '@address-book/sdk';
const info = await resolveByAddress('0xeeC5915A21DA64a58DE1e9a3D7dd7b8Bff775cF0')
// { info: { address: '0xeeC5915A21DA64a58DE1e9a3D7dd7b8Bff775cF0', avatar: 'base64...', nickname: '0xVinny', freeText: '...' }, resolvedAt: '...', resolvedBy: 'address' }
import { resolveByEmail } from '@address-book/sdk';
const info = await resolveByEmail('[email protected]')
// { info: { address: '0xeeC5915A21DA64a58DE1e9a3D7dd7b8Bff775cF0' avatar: 'base64...', email: '[email protected]', freeText: '...' }, resolvedAt: '...', resolvedBy: 'email' }
Advance
import AddressBook from '@address-book/sdk';
const client = new AddressBook({
rpcUrl: 'Your RPC',
contractAddress: 'Your Contract Address',
isTestnet: true
})
const info = client.resolveByNickname('0xVinny')
// { info: { address: '0xeeC5915A21DA64a58DE1e9a3D7dd7b8Bff775cF0' avatar: 'base64...', nickname: '0xVinny', freeText: '...' } , resolvedAt: '...', resolvedBy: 'nickname' }
API
AddressBook(options?: IAddressBookOptions)
IAddressBookOptions
Type: object
rpcUrl
Type: string | string[]
Default: https://optimism.llamarpc.com
contractAddress
Type: string
Default: 0x32b4aED2b805dAb72c4bAD5807fE8bBae2934fcd
isTestnet
Type: bool
showLog
Type: bool
cache?: CacheOptions
Type: object
cacheTime
Type: number
cacheCheckExists
Type: bool
cacheResolve
Type: bool