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 needs to:

  • Create data which is the content of transacting with a smart contract

  • Create value if needs to send the Ether to smart contract



address string

the sender address


address string

the smart contract address


hex string (0x prefix)

the content of transacting with a smart contract, can use library, such as Web3j, to generate

value (optional)


the amount of Ether deposit in the smart contract (if the smart contract accepts ether)

// Create data using web3j
val donateFunction = Function(
    listOf(Utf8String("Hi, Blocto")), 
val data = FunctionEncoder.encode(donateFunction)

// Create value using web3j
val value = Convert.toWei("1", Convert.Unit.ETHER).toBigInteger()

// Send transaction based on specific chain
    context = context,
    blockchain = Blockchain.ETHEREUM,
    fromAddress = fromAddress,
    toAddress = toAddress,
    data = data,
    value = value,
    onSuccess = { txHash ->
        // transaction sent
    onError = { error ->
        // handle error

Last updated