Skip to content

Commit

Permalink
chore: tsdoc - sendTransaction
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Sep 19, 2024
1 parent 1cffbc2 commit b8c47f3
Showing 1 changed file with 12 additions and 39 deletions.
51 changes: 12 additions & 39 deletions src/sdk/clients/decorators/smartAccount/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,23 @@ import { getAction, parseAccount } from "viem/utils"
import { AccountNotFoundError } from "../../../account/utils/AccountNotFound"

/**
* Creates, signs, and sends a new transaction to the network.
* This function also allows you to sponsor this transaction if sender is a smartAccount
* Creates, signs, and sends a new transaction to the network using a smart account.
* This function also allows you to sponsor this transaction if the sender is a smart account.
*
* - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html
* - Examples: https://stackblitz.com/github/wagmi-dev/viem/tree/main/examples/transactions/sending-transactions
* - JSON-RPC Methods:
* - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)
* - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)
*
* @param client - Client to use
* @param parameters - {@link SendTransactionParameters}
* @returns The [Transaction](https://viem.sh/docs/glossary/terms.html#transaction) hash.
* @param client - The client instance.
* @param args - Parameters for sending the transaction or user operation.
* @returns The transaction hash as a hexadecimal string.
* @throws {AccountNotFoundError} If the account is not found.
*
* @example
* import { createWalletClient, custom } from 'viem'
* import { mainnet } from 'viem/chains'
* import { sendTransaction } from 'viem/wallet'
*
* const client = createWalletClient({
* chain: mainnet,
* transport: custom(window.ethereum),
* })
* const hash = await sendTransaction(client, {
* account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* })
* import { sendTransaction } from '@biconomy/sdk'
*
* @example
* // Account Hoisting
* import { createWalletClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { mainnet } from 'viem/chains'
* import { sendTransaction } from 'viem/wallet'
*
* const client = createWalletClient({
* account: privateKeyToAccount('0x…'),
* chain: mainnet,
* transport: http(),
* })
* const hash = await sendTransaction(client, {
* to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
* value: 1000000000000000000n,
* const hash = await sendTransaction(nexusClient, {
* to: '0x...',
* value: parseEther('0.1'),
* data: '0x...'
* })
* console.log(hash) // '0x...'
*/
export async function sendTransaction<
account extends SmartAccount | undefined,
Expand Down

0 comments on commit b8c47f3

Please sign in to comment.