1.1.2 • Published 6 months ago

@cube3/sdk-ui v1.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

sdk-data

SDK-UI is used your DAPP's frontend. For you to do any transaction validations, you need to create an abstraction of that transaction. This SDK allows you to do so on the frontend level.

Example 1. In the DApp frontend, initialize a contract and connect it to a signer

import { ethers } from "ethers";

const signer = provider.getSigner();

const yourTokenContract = new ethers.Contract(
yourContractAddress,
yourContractAbi,
signer
);

const connectedTokenContract = yourTokenContract.connect(signer);
  1. Let’s populate transaction with a transfer method for validation. First, import our CUBE3 frontend library and create CUBE3 validation object. For that - use constructCube3Validation method that takes in two parameters - populatedTransaction object (Make sure to set chainId and value field, where value field is amount of ether being interacted with in the blockchain) and a boolean trackNonce used to determine whether to track nonce. But before pas
import {constructCube3Validation} from '@cube-web3/sdk-ui'

//Our previous code <...>

const txData = await connectedTokenContract.populateTransaction.transfer("to", amount)

//make sure to have your chainId and value defined inside this object
txData.chainId = 5;
txData.value = BigNumber.from(0);

const cube3TransactionData = await constructCube3Validation(txData, true);
  1. Send CUBE3 data to the DApp (your) backend with cube3TransactionData in the request body.
const requestParams = {
  method: "POST",
  body: JSON.stringify(cube3TransactionData)
}

const validationFetch = await fetch('<...>/api/validation', requestParams)```

Now to do the actual validation in your backend, use https://www.npmjs.com/package/@cube3/sdk-nodejs.

1.1.1

6 months ago

1.1.0

7 months ago

1.1.2

6 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago