Usage
Examples of basic use.
import Chainge, { ConfigOptions, ExecuteParams, StatusOptions } from '@chaigne/sdk'
const options: ConfigOptions = {
appKey: 'your appKey', // your appKey
secret: 'your secret', // your secret, as demonstrated here, a local signature is used
}
const chainge = new Chainge(options)
const transactionExecute = async () => {
const userAddress = 'Your wallet account address'
const params: ExecuteParams = {
evmAddress: userAddress,
feeLevel: 0,
fromAddress: userAddress,
fromAmount: '10',
fromChain: 'ETH',
fromToken: 'USDT',
toChain: 'BSC',
toToken: 'USDT',
}
const optionsObj: StatusOptions = {
mills: 3000, // Order status refresh frequency, milliseconds
progressCallback: (data) => {
// Cross-chain step state callback function
console.log(data)
},
orderCallback: (data) => {
// Order status callback function
console.log(data)
}
}
try {
await chainge.execute((window as any).ethereum, params, optionsObj)
} catch(error) {
// All errors will be shown here
console.log(error)
}
}
// execute
transactionExecute()
For a more detailed example, see here.
Last updated