โœ๏ธSigning a transaction

Easily use our EIP-1193 provider or custom built functions to make sending and signing transactions easier!

Signing

The Portal instance includes a number of helper functions to allow you to execute Provider requests without having to worry about encoding, request format, or what method to pass in your request. These helper functions allows you to easily sign and submit transactions, sign messages, and even sign typed data.

// eth_sign
const signature = await portal.ethSign('YOUR-MESSAGE')

// eth_signTransaction
const signature = await portal.ethSignTransaction(transaction)

// eth_sendTransaction
const transactionHash = await portal.ethSendTransaction(transaction)

// personal_sign
const signature = await portal.personalSign('YOUR-MESSAGE')

Raw Requests with the Provider

Estimating Gas

By default, Portal will estimate and populate the gas property in a transaction object if the property is undefined.

To estimate the gas value manually use the eth_estimateGas RPC call and pass in your transaction as the parameter.

const gas = await portal.provider.request({
    method: 'eth_estimateGas',
    params: [
        // partial transaction to estimate gas for
        {
            from:"0xFROMADDRESS",
            to:"0xTOADDRESS",
            value:"0xVALUE",
            input:"HASH_OF_CONTRACT_CALL_DATA", // only needed if calling a smart contract
        }
    ]
})

console.log(gas)
// "0x5208"

Using the Portal Provider with Third Party Libraries

The Portal Web3 Provider can also be used with third-party libraries just like any other Web3 Provider. This will enable you to interact with these libraries like normal, while utilizing Portal's MPC technology under the hood.

// Example with `ethers`
const ethersProvider = new ethers.providers.Web3Provider(portal.provider);

And now you are signing transactions with Portal! ๐Ÿ™Œ ๐Ÿš€ Next, we'll explore how to simulate a transaction so that you can create smoother experiences for your users.

Last updated