For the complete documentation index, see llms.txt. This page is also available as Markdown.

Send Transaction

Request

Sends coin.

Parameters

  • from : Account to send from

  • to: Account to send to

  • value: Amount in smallest unit such as wei

  • data : (optional)

curl --location --request POST "localhost:9680/rpc" \
--header 'Content-Type: application/json' \
--data-raw '{
    "request": {
        "method": "eth_sendTransaction",
        "params": [{
            "from": "0x638105AA1B69406560f6428aEFACe3DB9da83c64",
            "to": "0x638105AA1B69406560f6428aEFACe3DB9da83c64",
            "value": "123000000000000",
            "data": ""
        }]
    },
    "chain": {
        "chainId": "1"
    }
}'
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

public class SendTransaction: MonoBehaviour
{
    void Start()
    {
        StartCoroutine(Send());
    }

    private IEnumerator Send()
    {
        string jsonString = "{ \"request\": { \"method\": \"eth_sendTransaction\", \"params\": [{ \"from\": \"0x638105AA1B69406560f6428aEFACe3DB9da83c64\", \"to\": \"0x638105AA1B69406560f6428aEFACe3DB9da83c64\", \"value\": \"123000000000000\", \"data\": \"\" }] }, \"chain\": { \"chainId\": \"5\" } }";
        byte[] jsonBytes = System.Text.Encoding.UTF8.GetBytes(jsonString);

        UnityWebRequest request = new UnityWebRequest("localhost:9680/rpc", "POST");
        request.uploadHandler = new UploadHandlerRaw(jsonBytes);
        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        yield return request.SendWebRequest();
        Debug.Log(request.error);
        Debug.Log(request.downloadHandler.text);
    }
}

Response

The transaction hash

Errors will have an HTTP response status 500-599

Last updated