npm.io
1.0.1-beta5 • Published 11h ago

fsl-js-sdk

Licence
ISC
Version
1.0.1-beta5
Deps
58
Size
2.2 MB
Vulns
28
Weekly
0

FSL-ACCOUNT-SDK

What id FSL ID

Getting started

  • npm | yarn | pnpm install
import { FSLAuthorization } from 'fsl-js-sdk';

const fslAuthorization = FSLAuthorization.init({
  responseType: 'code', // 'code' | 'token'
  appKey: 'Your APP KEY',
  redirectUri: 'Your Redirect URL', // https://xxx.xxx.com
  scope: 'basic', // 'basic' | 'wallet'
  state: 'xyz',
  usePopup: true,
});

fSLAuthorization.signIn().then((code) => {
  if (code) {
    // todo your code
  }
});

callEvmSign

import { FSLAuthorization } from 'fsl-js-sdk';

// your Three-party login initialization
// ...

fSLAuthorization
  .callEvmSign({
    chainId: 137,
    msg: 'Your Sign Message',
  })
  .then((res) => {
    console.log('signedTx', res);
    const address = FSLAuthorization.evmVerifyMessage('Your Sign Message', res);
    // Check whether the resolved address is the same as the user address
  });
Types
 interface IEvmSign {
    msg: string;
    rpc?: string;
    chainId: number;
 }

callEvmContract

import { FSLAuthorization } from 'fsl-js-sdk';
import { ethers } from 'ethers';

// your Three-party login initialization
// ...

fSLAuthorization
  .callEvmContract({
    contractAddress: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
    methodName: 'transfer',
    params: ['0x...', ethers.BigNumber.from(Math.floor(10 * Math.pow(10, 6)))],
    abi: [
      {
        constant: false,
        inputs: [
          { name: '_to', type: 'address' },
          { name: '_value', type: 'uint256' },
        ],
        name: 'transfer',
        outputs: [{ name: '', type: 'bool' }],
        payable: false,
        stateMutability: 'nonpayable',
        type: 'function',
      },
    ],
    amount: '10',
    gasLimit: '100000',
    to: '0x...',
    chainId: 137,
  })
  .then((res) => {
    console.log('TransactionReceipt', res);
  });
Types

interface IEvmContract {
  contractAddress: string;
  methodName: string;
  chainId: number;

  abi?: any; // If the abi is not recognized, you can pass it in manually
  value?: string;
  amount?: string; // The number of tokens displayed on the page
  gasLimit?: string;
  params?: any[];
  to?: string;
  rpc?: string;
  tokenTicker?: string; // Specifies the name of the operation token
  tokenIcon?: string; // Specifies the picture of the operation token
  nonce?: number;

  maxPriorityFeePerGasValue?: ethers.BigNumber;
  maxFeePerGasValue?: ethers.BigNumber;
}

Join as Developers

  • Please prepare the necessary stuff and talk to an FSL guy for your interest. Here are some step guides
  1. Register an FSL ID at https://id.fsl.com, and setup all necessary information. This will be your developer ID. Please make sure your 2FA and seed phrase backup is well and safely kept.

  2. Tell us about your App/product in a sheet

    1. Name
    2. Icon images in 128128px and 512512px
    3. App/product description
    4. Official website
    5. Social network links
  3. Go through the API references and provide your CALLBACK URL and host.

Keywords