1-Click Transactions

1-click transactions

Pangea ID allows users to sign and execute blockchain transactions directly from your app without needing to open Pangea ID.

These transactions have lower security guarantees than wallet-signed transactions and are good for low-value actions such as creation proposals, updating settings or game actions.

1. Modify your Smart Contract

If you have deployed the smart contract to the same account as your Registered App, then you can get the permission name with get_self().

token.cpp
token::transfer(const name &from,
                        const name &to,
                        const asset &quantity,
                        const string &memo)
{
    require_auth({from, get_self()});
    // Rest of your code below...
}

2. Sign the Transaction in Your App

const trx = await user.signTransaction('eosio.token', 'transfer', {
    from: "me",
    to: "you",
    quantity: '1 SYS',
    memo: 'test memo',
});

This will directly sign the transaction and send it to the blockchain in the user's browser, without them needing to open Pangea ID. You may want to show a confirmation before, or after (such as with a Toast UI component).

If the contract is deployed to the Registered App, then the transaction does not communicate with Pangea ID. Otherwise, it will need to send a message to Pangea ID the first time it does this transaction to the contract.

This will prompt the user to sign the transaction in their Pangea ID mobile app.

Last updated