2.0.6 • Published 1 year ago

@1combo/1combo-ethereum-sdk v2.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

1combo-ethereum-sdk

image

Install

npm install @1combo/1combo-ethereum-sdk

Example

Basic usages

    import { config as loadEnv } from 'dotenv';
    import { randomBytes } from 'crypto';
    import { SDK, Auth, TEMPLATES, Chains } from '@1combo/1combo-ethereum-sdk';

    loadEnv();

    const pk = `0x${randomBytes(32).toString('hex')}`;
    const auth = new Auth({
        privateKey: pk, // wallet
        projectId: process.env.INFURA_PROJECT_ID,
        secretId: process.env.INFURA_PROJECT_SECRET,
        chainId: Chains.goerli, // choose network
    });
    const sdk = new SDK(auth);

    // Query gas price in Gwei
    const gas = await sdk.getGasPrice();

    // Query tx status
    const receipt = await sdk.getStatus({ txHash: '' });
    ...

Query royalty info

    import { config as loadEnv } from 'dotenv';
    import { randomBytes } from 'crypto';
    import { SDK, Auth, TEMPLATES, Chains } from '@1combo/1combo-ethereum-sdk';

    loadEnv();

    const pk = `0x${randomBytes(32).toString('hex')}`;
    const auth = new Auth({
        privateKey: pk,
        projectId: process.env.INFURA_PROJECT_ID,
        secretId: process.env.INFURA_PROJECT_SECRET,
        chainId: Chains.goerli,
    });
    const sdk = new SDK(auth);
    const combo = await sdk.loadContract({
        templateName: TEMPLATES.ComboCollCore,
        contractAddress: '0x0f1Da267B55d47d5aBced9be7542A6b3aE9b52B8',
    });

    const info = await combo.royaltyInfo({tokenId: 1, sellPrice: 10000});
    console.log(info);

Create set

    import { config as loadEnv } from 'dotenv';
    import { SDK, Auth, TEMPLATES, Chains, CONTRACT_ADDRESSES } from '@1combo/1combo-ethereum-sdk';

    loadEnv();

    const auth = new Auth({
        privateKey: process.env.KEY,
        projectId: process.env.INFURA_PROJECT_ID,
        secretId: process.env.INFURA_PROJECT_SECRET,
        chainId: Chains.goerli,
    });
    const sdk = new SDK(auth);
    const manager = await sdk.loadContract({
        templateName: TEMPLATES.SetManager,
        contractAddress: CONTRACT_ADDRESSES.GOERLI.SetManager,
    });

    await manager.createSet({
        name: 'Books',
        metadataURI: '',    // URI to metadata about this set, optional
        initialCategoryNames: ['P-Books', 'E-Books'],
        initialCategoryCollections: [],
        gasPrice: (parseFloat(await sdk.getGasPrice()) + 5).toString(),
    });
2.0.6

1 year ago

2.0.5

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.4

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago