@onboardmoney/sdk
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

@onboardmoney/sdk

wrap ethereum in sexy

Version Downloads/week License

Install

$ npm install @onboardmoney/sdk
$ yarn add @onboardmoney/sdk

Initialize

import {
  App,
  Policies,
  TxBatchInterface,
  TransactionReceipt,
} from '@onboardmoney/sdk'
import { PopulatedTransaction } from 'ethers'

const apiKey = 'ABCXYZ'
const network = 'mainnet' | 'ropsten' | 'rinkeby' | 'goerli' | 'kovan'
const onboardmoney = new App(apikey, `https://${network}.onboard.money`)

App

// Fetch application ETH balance and address for gas payments
const { balance, relayAddress } = await onboardmoney.balance()
// { balance: 1.5, relayAddress: 0x1234 }

// Create a new application user
const { userAddress } = await onboardmoney.createUser()

// Create user transaction batch
const txBatch = {
  txs: [
    {
      from: userAddress, // required: user wallet address from which to send transaction (msg.sender)
      to: '0x1234', // required: destination address
      value: '1000000000000000000', // optional: amount of ETH to send in wei
      data: '0xabcd', // optional: smart contract calldata
    },
  ] as PopulatedTransaction[],
} as TxBatchInterface

// Evaluate if a batch of user transactions would succeed
const { success } = await onboardmoney.evaluateBatch(txBatch)

// Send a batch of user transactions to the network
const txReceipt = await onboardmoney.sendBatch()

// Query the current trust policy
const { policy } = await onboardmoney.getPolicy()

// Set a new trust policy
const newPolicy = Policies.self | Policies.custodied | Policies.multisig // required: new trust policy
const signerAddress = '0x1234' // optional: application signer address (only for 'self' and 'multisig' trust policy)
await onboardmoney.updatePolicy(newPolicy, signerAddress)

// Create user transaction batch with 'self' or 'multisig' trust policy
// Helper methods in development. Contact team for support on how to craft required data.
const txBatch = {
  txs: [
    {
      from: userAddress, // required: user address to send transaction from
      to: '0x1234', // required: destination address
      value: '1000000000000000000', // optional: amount of ETH to send in wei
      data: '0xabcd', // optional: smart contract calldata
      gasLimit: '100000', // required: gas limit permitted
      nonce: 15, // required: user wallet nonce
    },
  ] as PopulatedTransaction[],
  gasPrice: '10000000000', // optional: gas price in wei
  signatures: ['0xabcd'], // optional: application signature
} as TxBatchInterface

/@onboardmoney/sdk/

    Package Sidebar

    Install

    npm i @onboardmoney/sdk

    Weekly Downloads

    0

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    28.7 kB

    Total Files

    23

    Last publish

    Collaborators

    • thegostep
    • budibudibudi