Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 1.77 KB

address.md

File metadata and controls

46 lines (36 loc) · 1.77 KB

Use Scallop Address

Read Addresses

General Users will basically only use the read, switchCurrentAddresses, get, getAddresses, or getAllAddresses methods to read addresses. Here are some simple examples:

const scallopAddress = new ScallopAddress({
  id: TEST_ADDRESSES_ID,
  network: NETWORK,
});

// Fetch addresses data from Scallop Addresses API.
await scallopAddress.read();
// Get the address in the nested address structure through the dot symbol.
const address = scallopAddress.get('core.coins.usdc.id');
// Get current addresses or specific network addresses of lending protocol.
const addresses = scallopAddress.getAddresses();
// Get all network addresses of lending protocol.
const allAddresses = scallopAddress.getAllAddresses();
// Synchronize addresses from addresses map of the specified network to the current addresses of instance.
const currentAddresses = scallopAddress.switchCurrentAddresses('testnet');

Scallop currently maintains this addresses id 6462a088a7ace142bb6d7e9b for use in the production environment.

Of course, you can also directly use the sui-scallop-api project to directly request addresses.

Write Addresses

The rest of the features are for Scallop administrators to use, and require a set of API authentication keys to use the create, update, and delete address functions.

  const scallopAddress = new ScallopAddress({
    id: TEST_ADDRESSES_ID,
    auth: process.env.API_KEY,
    network: NETWORK,
  });

  // create addresses.
  const addresses = await scallopAddress.create({...});
  // Update addresses by id.
  const allAddresses = await scallopAddress.update({...});
  // delete addresses by id.
  const allAddresses = await scallopAddress.delete(id);