Send Transaction
Make sure you initialize Blocto SDK first
Once your app is connected to Blocto wallet, it can send transactions on behalf of the user, with the user's permission.
In order to send a transaction, the app must:
  • Create an Ethereum transaction base on predefined type EVMBaseTransaction.
  • Have it be signed by the user's Blocto wallet.
  • Send it with Blocto custom JSON-RPC.
For more information about the transaction on EVMBase, it is recommended to check out the Ethereum Web3 as well as official Ethereum docs.
Send Transaction
1
let evmBaseTransaction = EVMBaseTransaction(
2
to: "0x...", // contract address that user want to interact with.
3
from: "0x...", // user address.
4
value: "0x64", // 100 wei hex string with 0x prefix, default is 0.
5
data: functionData) // functionData stands for data in ethereum transaction, default is Empty data.
6
BloctoSDK.shared.ethereum.sendTransaction(
7
transaction: evmBaseTransaction
8
) { [weak self] result in
9
guard let self = self else { return }
10
switch result {
11
case let .success(txHsh):
12
// handle txHash here.
13
case let .failure(error):
14
// handle error here.
15
}
16
}
Copied!
Copy link