liquality / chainify

Blockchain abstraction layer
https://liquality.io
MIT License
219 stars 69 forks source link

feat: Integrate moralis as nft provider #548

Closed AndonMitev closed 2 years ago

kraikov commented 2 years ago

Usage:

import * as EVM from "@chainify/evm";

const infuraApi = "";
const mnemonic = "";

const chainProvider = new EVM.EvmChainProvider(
  {
    ...EVM.EvmNetworks.rinkeby,
    rpcUrl: `https://rinkeby.infura.io/v3/${infuraApi}`,
  },
  null,
  null,
  false
);

const walletProvider = new EVM.EvmWalletProvider({ mnemonic }, chainProvider);

// Fetch NFTs from OpenSea
const openSea = new EVM.OpenSeaNftProvider(walletProvider, {
  url: "https://rinkeby-api.opensea.io/api/v1/",
  apiKey: undefined, // define for mainnet
});
openSea.fetch().then(openSea.fetch().then(console.log()));

// Fetch NFTs from Moralis
const moralis = new EVM.MoralisNftProvider(walletProvider, {
  url: "",
  apiKey: "",
  appId: "",
});
moralis.fetch().then(console.log);

// Fetch NFTs from Covalent (does not work with Rinkeby)
const covalent = new EVM.CovalentNftProvider(walletProvider, {
  url: "https://api.covalenthq.com/v1",
  apiKey: "",
});
covalent.fetch().then(console.log);

// Transfer
moralis
  .transfer(
    "0xe10cd16070101ffe6b5bdd380c3c7f0e8fcec84d", // nft contract address
    "0x8072aC361d0ee237EFE0883198613d8d121Ee98d", // recipient
    ["1"], // token ids
    ["1"] // token amounts only applicable for ERC1155
  )
  .then(console.log);
kraikov commented 2 years ago

Responses:

OpenSea:

[
  {
    asset_contract: {
      address: '0xe10cd16070101ffe6b5bdd380c3c7f0e8fcec84d',
      external_link: null,
      image_url: null,
      name: 'test1',
      symbol: 'test1'
    },
    collection: { name: 'test1 - uRJXEljW05' },
    description: 'Bitcoin, often described as a cryptocurrency, a virtual currency or a digital currency - is a type of money that is completely virtual.',
    external_link: null,
    id: 57292149,
    image_original_url: 'ipfs://QmWsDVqrE5wp2ct6CxXzRaZeG8QxuJR7ALiuLaKrJ1UvYf/0000000000000000000000000000000000000000000000000000000000000001.png',
    image_preview_url: 'https://lh3.googleusercontent.com/rfjtgTE04GAX2WhKqDTFx1ZHd-uJEdhqD9XCyIDurHTr5KoBthbAl1s_LUJ1-2XSVZRoObd40J68mNuq8QpX7ZNBdoWfdr-JCA7fU5c=s250',
    image_thumbnail_url: 'https://lh3.googleusercontent.com/rfjtgTE04GAX2WhKqDTFx1ZHd-uJEdhqD9XCyIDurHTr5KoBthbAl1s_LUJ1-2XSVZRoObd40J68mNuq8QpX7ZNBdoWfdr-JCA7fU5c=s128',
    name: 'test1',
    token_id: '1'
  }
]

Moralis:

[
  {
    asset_contract: {
      address: '0xe10cd16070101ffe6b5bdd380c3c7f0e8fcec84d',
      name: 'test1',
      symbol: 'test1'
    },
    collection: { name: 'test1' },
    token_id: '1',
    name: 'Bitcoin 1',
    description: 'Bitcoin, often described as a cryptocurrency, a virtual currency or a digital currency - is a type of money that is completely virtual.',
    image_original_url: 'ipfs://QmWsDVqrE5wp2ct6CxXzRaZeG8QxuJR7ALiuLaKrJ1UvYf/0000000000000000000000000000000000000000000000000000000000000001.png',
    image_preview_url: 'ipfs://QmWsDVqrE5wp2ct6CxXzRaZeG8QxuJR7ALiuLaKrJ1UvYf/0000000000000000000000000000000000000000000000000000000000000001.png',
    image_thumbnail_url: 'ipfs://QmWsDVqrE5wp2ct6CxXzRaZeG8QxuJR7ALiuLaKrJ1UvYf/0000000000000000000000000000000000000000000000000000000000000001.png',
    external_link: undefined
  }
]

Covalent

[
  {
    token_id: '36500',
    asset_contract: {
      address: '0xaaf03a65cbd8f01b512cd8d530a675b3963de255',
      name: 'Seekers',
      symbol: 'SEEKERS'
    },
    collection: { name: 'Seekers' },
    name: null,
    description: null,
    external_link: 'https://seekers.xyz',
    image_original_url: 'https://nft.seekers.xyz/seekers/seeker_36500.png',
    image_preview_url: 'https://nft.seekers.xyz/seekers/seeker_36500.png',
    image_thumbnail_url: 'https://nft.seekers.xyz/seekers/seeker_36500.png'
  }
]