Sender Wallet Developer Documentation
  • Guide
    • Introduction
    • Getting Started
    • Sign in Applications
      • Sign in Applications in Near
      • Sign in Applications in Ethereum
    • Access Accounts
      • Access Accounts in Near
      • Access Account in Ethereum
    • Send Transactions
      • Send Transactions in Near
      • Send Transactions in Ethereum
  • API Reference
    • Near
      • NEAR Provider API
      • Deprecated APIs
    • Ethereum
      • Sign Data
      • Ethereum Provider API
    • Ton
      • Mobile Dapp Provider
  • Best Practices
    • Define App's Icon
Powered by GitBook
On this page
  1. Guide
  2. Send Transactions

Send Transactions in Ethereum

PreviousSend Transactions in NearNextNear

Last updated 2 years ago

You can send a transaction in Sender using the RPC method.

For example, the following JavaScript gets the user's accounts and sends a transaction when they select each button, and the following HTML displays the buttons.

const ethereumButton = document.querySelector('.enableEthereumButton');
const sendEthButton = document.querySelector('.sendEthButton');

let accounts = [];

// Send Ethereum to an address
sendEthButton.addEventListener('click', () => {
  sender.ethereum
    .request({
      method: 'eth_sendTransaction',
      params: [
        {
          from: accounts[0], // The user's active address.
          to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970', // Required except during contract publications.
          value: '0x29a2241af62c0000', // Only required to send ether to the recipient from the initiating external account.
          gasPrice: '0x09184e72a000', // Customizable by the user during MetaMask confirmation.
          gas: '0x2710', // Customizable by the user during MetaMask confirmation.
        },
      ],
    })
    .then((txHash) => console.log(txHash))
    .catch((error) => console.error(error));
});

ethereumButton.addEventListener('click', () => {
  getAccount();
});

async function getAccount() {
  accounts = await sender.ethereum.request({ method: 'eth_requestAccounts' });
}
<button class="enableEthereumButton btn">Enable Ethereum</button>
<button class="sendEthButton btn">Send ETH</button>
eth_sendTransaction