πAddress Book
Explains how to manage the address book.
Every Dev3 user gets his own address book space.
Address book is nothing but a large mapping of your contacts where you can assign a real identities to the blockchain addresses you often interact with.
Every address book entry fetched or created using the address book contains the following data:
{ // address book entry model
id: '<unique id of the address book entry>',
alias: '<alias assigned to the address book entry>',
address: '<blockchain address assigned to the entry>',
phone_number: '<phone number>',
email: '<email assigned to the address book entry>',
created_at: '<timestamp>'
}Only authorized users can edit their address book entries.
Requests to manage and read the address book are shown below. Before running any of them, you have to obtain the User object connection. This is explained in the User Authentication section.
Creating new entry
// user object obtained
const newEntry = await user.addToAddressBook({
address: '0x4Ed918C7800F5dc34d2C774f6EA5fbd15f1a94a7',
alias: 'random-addr',
phone_number: '+123456789', // phone number is optional
email: '[email protected]' // email is optional
});
console.log(`entry created, id: ${newEntry.id}`);Update existing entry
Fetch entry by alias
Fetch all entries
Live example
Run this flow on a live coding environment here!
Last updated