0.1.2 • Published 2 years ago

omnite-sdk v0.1.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Omnite SDK

API docs

API documentation is available under docs/index.html.

Examples

Initialize (required for package to work)

await config.initialize({
    supportedChains: [
        // supported chains for project
        ChainId.BSCT,
        ChainId.RINKEBY,
    ],
    moralisApiKey: '',
    pinataJWTToken: '',
    providerRpcUrls: {
        // taken from https://chainlist.org/, private RPC URLs can be used too
        [ChainId.BSCT]: 'https://data-seed-prebsc-1-s1.binance.org:8545/',
        [ChainId.RINKEBY]:
            'https://rinkeby.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
    },
});

Omnichain deployment

const collectionCreator = new CollectionCreator(
    chainId,
    wallet,
    DeployType.native,
    {
        collectionName: 'My omnichain collection',
        collectionTicker: 'MOC',
        userAddress: '0x21453911eb364c7DF9291d2f427fd04Fa7234667',
    },
    [BridgeBroker.LayerZero, BridgeBroker.Axelar], // which broker should be supported, could be Axelar and LayerZero
    BridgeBroker.LayerZero, // which broker should be used to deploy new collection
    [
        { amount: 10, chainId: '0x4' }, // deploy collection on Rinkeby with 10 available slots (1-10)
        { amount: 20, chainId: '0x61' }, // deploy collection on BSCT with 20 available slots (11-30)
    ]
);

collectionCreator.baseTokenUri =
    'ipfs://QmNNvuUaB5cd8mP7oMhcEeax1AMSHcWfp2GzY3YfoZJLD3/'; // base token uri, will be concatenated with token id if tokenURI is requested. Eg. ipfs://QmNNvuUaB5cd8mP7oMhcEeax1AMSHcWfp2GzY3YfoZJLD3/11 for tokenId 11

const result = await collectionCreator.deploy(); // regular ethers tx result
await result.wait(); // wait for the tx to be confirmed once

Crosschain minting

// signer is ethers.providers.JsonRpcProvider
const collection = new Collection(
    signer,
    '0x29d9b96fb1e6df756669ff694c87a14c70e5810d'
); // 0x29d9b96fb1e6df756669ff694c87a14c70e5810d is the collection address on the source chain

const result = await collection.mintOnTargetChain(
    '0x61', // mint on BSCT chain
    BridgeBroker.LayerZero, // which broker should be used for minting
    {
        tokenId: BigNumber.from(11), // token ID to be minted
    },
    'QmNNvuUaB5cd8mP7oMhcEeax1AMSHcWfp2GzY3YfoZJLD3' // tokenURI, used if no baseTokenUri is defined for collection
);