🚀
Tonomy Developer Docs
  • Introduction
    • Features
  • Build Web4 Apps
    • Install
    • Register your Web4 App
    • Login
    • User Data and Logout
    • Sign Verifiable Credentials
    • Server Authentication
    • Smart Contracts
      • Develop
      • Deploy
      • 1-Click Transactions
      • Wallet Signing
    • Send P2P Messages
    • Troubleshooting
  • Multi-Chain Transactions + Crypto
    • Wallet Connect
    • Antelope Sigining Request (ESR)
  • Run Tonomy Infrastructure
    • Overview
      • Configuration
      • What software to run?
    • Node Setup
      • Setup
      • Run an API Node
      • Run a Block Producer Node
      • Becoming a Block Producer on Tonomy
    • API Endpoints
    • Hardware Requirement
    • Troubleshooting
  • Connect as an Exchange
  • Run Tonomy Gov OS
    • Technical requirements
    • Deploy Tonomy ID
    • Deploy a web wallet with the SDK
    • Reference
      • Application Interface (API)
      • Software Development Kit (SDK)
    • Troubleshooting
Powered by GitBook
On this page
  • 1-click transactions
  • 1. Modify your Smart Contract
  • 2. Sign the Transaction in Your App
  1. Build Web4 Apps
  2. Smart Contracts

1-Click Transactions

PreviousDeployNextWallet Signing

Last updated 1 month ago

1-click transactions

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

These transactions have lower security guarantees than 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 , 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...
}

If your smart contract is deployed to a different account than your , then you can use a helper function to look up the permission name with the origin or username.

token.cpp
#include <tonomy/tonomy.hpp>

token::transfer(const name &from,
                        const name &to,
                        const asset &quantity,
                        const string &memo)
{

    require_auth({from, tonomysystem::tonomy::get_app_permission_by_origin("https://your-registered-app.com")});
    // or
    require_auth({from, tonomysystem::tonomy::get_app_permission_by_username("your-registered-app.app.demo.tonomy.id")});
    // 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 Tonomy 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 Tonomy ID. Otherwise, it will need to send a message to Tonomy ID the first time it does this transaction to the contract.

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

wallet-signed transactions
Registered App
Registered App