Onyx Protocol
  • 📖Onyx Documentation
  • ☕Getting Started
    • 🔬Networks
    • 📒Protocol Math
      • oToken and Underlying Decimals
      • Interpreting Exchange Rates
      • Calculating Accrued Interest
      • Calculating the APY Using Rate Per Block
    • 💹Gas Costs
  • 🧑‍💻OTokens
    • Mint
    • Redeem
    • Redeem Underlying
    • Borrow
    • Repay Borrow
    • Repay Borrow Behalf
    • Transfer
    • Liquidate Borrow
    • Key Events
    • Error Codes
    • Failure Info
    • Exchange Rate
    • Get Cash
    • Total Borrow
    • Borrow Balance
    • Borrow Rate
    • Total Supply
    • Underlying Balance
    • Supply Rate
    • Total Reserves
    • Reserve Factor
  • ⚙️Comptroller
    • Enter Markets
    • Exit Market
    • Get Assets In
    • Collateral Factor
    • Get Account Liquidity
    • Close Factor
    • Liquidation Incentive
    • Key Events
    • Error Codes
    • Failure Info
    • XCN Distribution Speeds
    • Claim XCN
    • Market Metadata
  • 👨‍👩‍👦Governance
    • Governor Alpha
    • Quorum Votes
    • Proposal Threshold
    • Proposal Max Operations
    • Voting Delay
    • Voting Period
    • Propose
    • Queue
    • Execute
    • Cancel
    • Get Actions
    • Get Receipt
    • State
    • Cast Vote
    • Cast Vote By Signature
    • Timelock
    • Pause Guardian
  • 🔡API
    • Basic API
      • GET: /otoken
      • GET: /market_history/graph
      • GET: /user/history
      • GET: /get_liquidators
      • GET: /get_liquidator:account
      • GET: /get_liquidator_detail:account
      • GET: /liquidator
    • GraphQL API
      • oTokens Subgraph
      • History Subgraph
      • Governance Subgraph
    • Governance API
      • GET: /proposal
      • GET: /proposal/:proposalId
      • GET: /voter/:proposalId
      • GET: /voter/accounts
      • GET: /voter/history/:address
    • Shared Data Types
  • 📖Onyx.js
    • Onyx Constructor
    • API Methods
      • Account
      • oToken
      • Market History
      • Governance
    • oToken Methods
      • Supply
      • Redeem
      • Borrow
      • Repay Borrow
    • XCN Methods
      • To Checksum Address
      • Get XCN Balance
      • Get XCN Accrued
      • Claim XCN
      • Delegate
      • Delegate By Sig
      • Create Delegate Signature
    • Comptroller Methods
      • Enter Markets
      • Exit Market
    • Ethereum Methods
      • Read
      • Trx
      • Get Balance
    • Governance Methods
      • Cast Vote
      • Cast Vote By Sig
      • Create Vote Signature
    • Price Feed Methods
      • Get Price
    • Utility Methods
      • Get Address
      • Get ABI
      • Get Network Name With Chain ID
  • 🔒Security
    • Bug Bounty Program
  • 📄Terms of Service
Powered by GitBook
On this page
  1. Onyx.js
  2. Ethereum Methods

Trx

This is a generic method for invoking JSON RPC's eth_sendTransaction with Ethers.js. Use this method to create a transaction that invokes a smart contract method. Returns an Ethers.js TransactionResponse object.

  • address (string) The Ethereum address the transaction is directed to.

  • method (string) The smart contract member in which to invoke.

  • [parameters] (any[]) Parameters of the method to invoke.

  • [options] (CallOptions) Options to set for eth_sendTransaction, (as JSON object), and Ethers.js method overrides. The ABI can be a string optional ABI of the single intended method, an array of many methods, or a JSON object of the ABI generated by a Solidity compiler.

  • RETURN (Promise<any>) Returns an Ethers.js TransactionResponse object or an error object if the transaction failed.

  • market (string) A string of the symbol of the market to exit.

  • [options] (CallOptions) Call options and Ethers.js overrides for the transaction. A passed gasLimit will be used in both the approve (if not supressed) and mint transactions.

  • RETURN (object) Returns an Ethers.js transaction object of the exitMarket transaction.

const oneEthInWei = '1000000000000000000';
const oEthAddress = '0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5';
const provider = window.ethereum;

(async function() {
  console.log('Supplying ETH to the Onyx Protocol...');

  // Mint some oETH by supplying ETH to the Onyx Protocol
  const trx = await Onyx.eth.trx(
   oEthAddress,
    'function mint() payable',
    [],
    {
      provider,
      value: oneEthInWei
    }
  );

  // const result = await trx.wait(1); // JSON object of trx info, once mined

  console.log('Ethers.js transaction object', trx);
})().catch(console.error);
PreviousReadNextGet Balance

Last updated 1 year ago

📖