Welcome to Dev3
  • ➕Create a Dev3 App
  • 🤖SDK
    • 📖Introduction
    • ⚙️Initialization
    • ➡️Importing Contracts
    • 🤝User Authentication
      • Options
    • 🔍Query Contracts
      • Function Parameters
    • ⚡Execute Contracts
      • Execution Options
    • 🛠️Deploy Contracts
      • Deployment Options
    • 📖Address Book
    • ❓FAQ
      • Out of gas error
  • INTEGRATIONS
    • 🔷Chainlink Feeds
    • 🔷Chainlink Subscriptions
      • 🎲VRF Subscriptions
      • 🧮Functions Subscriptions
      • 🤖Upkeep Subscriptions
    • 🎆OriginTrail DKG
    • 📽️OriginTrail DKG Video Tutorial
    • 📊Polyflow Analytics
  • Pricing
    • 💸Dev3 Pricing Plans
    • 💸Polyflow Pricing Plans
  • 🚀Guides
    • 👾Launching an NFT Collection
      • Step 1: Upload assets
      • Step 2: Upload metadata
      • Step 3: Deploy contracts
  • 🏫Resources
    • 👨‍💻Developer Resources
Powered by GitBook
On this page
  • Creating new entry
  • Update existing entry
  • Fetch entry by alias
  • Fetch all entries
  • Live example
  1. SDK

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: 'john@doe.com'       // email is optional
});
console.log(`entry created, id: ${newEntry.id}`);

Update existing entry

// user object obtained
const existingEntryId = '<address book entry id>';
const updatedEntry = await user.updateAddressBook({
  id: existingEntryId,
  address: "<new address | or old value>",
  alias: "<new alias | or old value>",
  phone_number: "<new phone number>", // phone number is optional
  email: "<new email>"                // email is optiona;l
});

Fetch entry by alias

// user object obtained
const entryAlias = '<existing alias in addressbook>';
const fetchedEntry = await user.getFromAddressBook(entryAlias);

Fetch all entries

// user object obtained
const allEntries = await user.getAllFromAddressBook();
// returns the list of all address book entries

Live example

PreviousDeployment OptionsNextFAQ

Last updated 2 years ago

Run this flow on a live coding environment

🤖
📖
here!