Skip to content

Bcode SDK

BcodeSDK is the easiest way to interact with BCode API service.

Let's get started!

BCode service has said before is build on top of Polygon blockchain so we have support MUMBAI network, for development and testing, and MAINNET network, for production environemnt.

One important concept to understand is that BCode service works with PTK Token a ERC20 token used as coin to execute transaction. This token can be obtain by a call with SDK for development environment, differently in production mode you have to contact our commercial section to sign a subscription that suits your need.

Installation

From npm:

npm install --save @bcode-tech/bcode-sdk

or

yarn add @bcode-tech/bcode-sdk

Initialization

First of all to get access to the service you have to request an api key to our development team. This API Key will allow you to request a JWT token for authentication and enable all the functionalies.

BcodeSDK can be use by creating an instance of it and running init function to exchange the auth data with the API service. Private key field is optional if not specified BcodeSDK will create a random wallet for you, it's always possible to change wallet later.

In config you can specify:

  • env: MUMBAI | POLYGON
  • debugMode: true | false (It enables verbose log)
  • rpcProvider: You can specify custom RPC for the selected network
const { BcodeSDK } = require("@bcode-tech/bcode-sdk");

(async () => {
  const sdk = new BcodeSDK({
    apiKey: "your-api-key",
    privateKey: "your_private_key",
    config: { env: "MUMBAI", debugMode: true },
  });

  await sdk.init();
})();

It's possible to change private key later in the script if you have necessity, by running:

sdk.setPrivateKey("private_key");

That's all you need to initialize BcodeSDK, now you can execute every smart contract function you need.