Connect
Cometh ConnectCometh MarketplaceCometh Checkout
  • Demo
  • 🚀QUICKSTART
    • What is Connect
    • Getting started
    • Supported Networks
    • Connect 4337
  • ⚒️FEATURES
    • Create a wallet
    • Send transactions
    • Sign/Verify a message
    • Retrieve a wallet Address
    • Import a Safe wallet
    • Handle wallet owners
  • 🔌Integrations
    • Ethers
    • Wagmi - Viem
      • Viem
      • Wagmi
      • Wagmi + Rainbowkit
      • Wagmi + Web3modal
    • Unity
    • React issues
      • Vite
      • Create React App
  • 📖RESOURCES
    • FAQ
    • Advanced features
      • Add a new device
      • Recover users wallets
    • General concepts
      • Biometric signers
      • Multiple devices
      • Account Recovery
      • Gasless transaction
Powered by GitBook
On this page
  1. FEATURES

Send transactions

Sending Web3 transactions has never been easier

Last updated 10 months ago

Considering that the authentication part is done, you can start to send transactions. You'll just need to create the transaction and send it to the SDK.

Depending on the UX you want to provide, there are different ways of sending transactions.

Send a single transaction

You can build a transaction object containing the targeted contract address, the value of the transaction, and the associated data in the transaction. This payload can be passed to the sendTransaction method of the SDK. A promise is returned by the method to wait for the validation of the transaction.

If this is the first transaction of the wallet, this sendTransaction will automatically be converted to a multi-call doing 2 transactions in one: deploy the Safe smart wallet and send the transaction

const txParams = {
   to: recipient,
   value: "0x00",
   data: "0x",
 };
      
 
 const tx = await wallet.sendTransaction(txParams);
 const txPending = await provider.getTransaction(tx.safeTxHash); 
 const txReceipt = await txPending.wait();
var safeTxHash = await _wallet.SendTransaction(to, value, data);
var transactionReceipt = await _wallet.Wait(safeTxHash);

The user will have to sign before the transaction is sent.

Send a Gasless transaction

With Cometh Connect, you can pay the transaction gas fees of your users. You will need to add the contract address of your transaction as a sponsored address for your project. Remember, the contract address corresponds to the "to" field of your transaction.

Here is the API route to create the sponsored address:

After doing so, you'll be able to send gasless transactions.

Send transactions batches

With Cometh Connect, you can execute multiple actions in the same transaction. To do so you can call the sendBatchTransactions method.

const txParams = [{
   to: targetAddress1,
   value: "0x00",
   data: "0x",
 }, {
   to: targetAddress2,
   value: "0x00",
   data: "0x",
 }];
      
 
 const tx = await wallet.sendBatchTransactions(txParams);
 const txPending = await provider.getTransaction(tx.safeTxHash); 
 const txReceipt = await txPending.wait();
coming soon

In the same way, you'll then be asked to validate the transaction.

Send a transaction using a contract interface

import {
  ComethWallet,
  ConnectAdaptor,
  ComethProvider,
  SupportedNetworks
} from '@cometh/connect-sdk'

const walletAdaptor = new ConnectAdaptor({
  chainId: YOUR_CHAIN_ID,
  apiKey: API_KEY
})

const wallet = new ComethWallet({
  authAdapter: walletAdaptor,
  apiKey: API_KEY,
  rpcUrl: RPC_URL
})

const provider = new ComethProvider(wallet)

const nftContract = new ethers.Contract(
  NFT_CONTRACT_ADDRESS,
  nftContractAbi,
  provider.getSigner()
)

const tx = await nftContract.count()
const txReceipt = await tx.wait()

To enable that feature, please contact us by

Another approach would be to use the provider offered by the SDK. You will need to instantiate the ComethProvider ( an Ethereum provider following ), using the ComethWallet. You can then use your contract interface to directly call the contract methods. Checkout our Getting started for more details.

⚒️
planning a meeting
EIP-1193
  • Send a single transaction
  • Send a Gasless transaction
  • POSTCreate sponsored address
  • Send transactions batches
  • Send a transaction using a contract interface

Create sponsored address

post

Create a new sponsored address for the project. The project is deduced from the API key.

Header parameters
apisecretstringRequired

A string representation of a customer ApiSecret.

Example: 78d8e101a-9154-4000-91c5-b02527f4c70e
Body
targetAddressstringOptional

An EVM address

Example: 0x1396698619C2ba28420F78d120f5b683EC378c6bPattern: ^0x[a-fA-F0-9]{40}$
Responses
200
Status of request
application/json
500
Internal server error
application/json
post
POST /sponsored-address HTTP/1.1
Host: api.connect.cometh.io
apisecret: 78d8e101a-9154-4000-91c5-b02527f4c70e
Content-Type: application/json
Accept: */*
Content-Length: 62

{
  "targetAddress": "0x1396698619C2ba28420F78d120f5b683EC378c6b"
}
{
  "success": true
}