Transaction

Transaction React Widgets and Modals

Get Method Widgets and Modals

To use the widgets in React components you need to import the Widget component:

import { Widget } from '@paytweed/frontend-sdk-react'

Every widget has an optional parameter called settings.

NameTypeRequiredDefaultDescription

fullScreen

Boolean

true

Should widget be shown fullscreen

hideMenu

Boolean

true

Deprecated

preventClose

Boolean

true

Hides close button

You can provide them to the widget like this:

<Widget settings={{hideMenu: false}}>

Batch transaction

Description

Sign and send a batched transaction to the chain. This function is used to maintain an ACID property on the chain for several transactions that need to be sent together. The function will display + a widget for the user to sign the transaction. The user can learn about all the transactions that they are about to sign - but will only need to approve it once.

Usage Example

// Some code

Parameters

NameTypeRequiredDefaultDescription

Transactions

String

✔️

The JSON object of the batched transactions

BlockchainId

any

✔️

Blockchain to send the trnasaction to


Send

Description

Send a raw transaction to the blockchain. This method is used mainly to control smart contracts. Returns a URL of a widget for a modal where the user can approve the transaction.

Parameters

NameTypeRequiredDefaultDescription

blockchainId

String

✔️

Blockchain ID

payload

any

✔️

Transaction payload

onClose

() => void

Close callback

onError

() => void

Error callback

Return type

Promise<string>

Usage Example

import { TezosToolkit } from '@taquito/taquito'
import {useEffect, useState} from 'react'

const tezos = new TezosToolkit('https://mainnet.api.tez.ie')

const App = () => {
  const [payload, setPayload] = useState()
  useEffect(() => {
    const contract = await tezos.contract.at('KT1REEb5VxWRjcHm5GzDMwErMmNFftsE5Gpf') //USDS contract address
    const rawTransaction = await contract.methods['transfer']([
      {
        from_: "FROM_WALLET_ADDR",
        txs: [
          {
            to_: "TO_WALLET_ADDR",
            token_id: '0',
            amount: '0',
            value: '0'
          }
        ]
      }
  ]).toTransferParams()
  setPayload(rawTransaction)
  }, [])
  return payload ? <Widget.Transaction.Send blockchainId='tezos' payload={payload} /> : null
}

Last updated