Skip to content

Commit

Permalink
feat: zkSync Extensions (#1665)
Browse files Browse the repository at this point in the history
* Applied zkSync changes onto main.

* Added documentation.

* chore: tweaks

* Small fixes

* feat: vocs (#1675)

* chore: canary

* chore: export types

* chore: remove unecessary type export

* chore: export version

* refactor: contract types

* chore: export

* refactor: generics

* refactor: contract types

* refactor: multicall types

* test: multicall types

* refactor: multicall response

* test: multicall types

* refactor: multicall results

* chore: export type

* chore: prettify type

* refactor: contract types

* refactor: contract function generics

* refactor: contract function args generic tweaks

* chore: prettify chain

* chore: update changeset

* chore: remove version export

* chore: restore version

* fix: type error

* refactor: abi types

* wip: types

* wip: types

* chore: fix type test

* chore: checkpoint

* fix: explicit undefined

* chore: ignore changes

* chore: export types

* refactor: simulate contract return type

* fix: transport generic

* refactor: eventName generics

* refactor: simplify poll options

* refactor: consolidate poll options

* fix: test

* chore: update snapshots

* ci: update version in snapshot

* ci: tweak

* chore: export abis

* chore: update snapshot

* chore: update snap

* chore: fix imports

* chore: enter alpha

* chore: update

* chore: add timeout

* chore: types

* chore: bump version

* chore: export types

* fix: type exports

* chore: bump version

* chore: clean up write contract types

* chore: bump version

* chore: update multicall type

* chore: bump version

* chore: version

* chore: export type

* chore: version

* chore: version

* ci: bump release timeout

* chore: version

* feat: refactor getContract

* docs: getContract

* chore: remove entrypoints

* chore: remove note

* fix

* fix: simulateContract account type

* fix

* chore: version

* refactor: chain

* chore: bump abitype

* chore: bump version

* chore: snaps

* docs: chains

* chore: snaps

* chore: snaps

* chore: bump version

* chore: add missing type

* chore: bump version

* test: update snaps

* chore: prettify chain

* refactor: defineChain

* refactor: defineChain type

* chore: remove

* docs: defineChain

* fix: downstream type error

* chore: beta

* chore: remove deprecated things

* docs: chains

* chore: update snaps

* refactor: contract function types

* chore: bump version

* feat: opstack (fees/gas actions) (#1469)

* wip: opstack init

* feat: total gas

* feat: total gas

* feat: imports

* docs: migration guide

* feat: exports

* docs: celo

* docs

* feat: fees

* feat: contract fee/gas estimation

* feat: exports

* feat: exports

* chore: docspath

* chore: update snaps

* docs: address

* docs: sidebar

* tests: fix

* fix: exports

* docs: fix links

* docs: typos

* Update site/docs/op-stack/client.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Fee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Gas.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractTotalFee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Gas.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Fee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* chore: export

* chore: pr review

* docs: updatE

---------

Co-authored-by: Will Cory <willcory10@gmail.com>

* chore: bump version

* docs: op stack

* docs: dead links

* refactor: rename

* chore: version

* fix: typo

* chore: merge

* refactor: opstack

* fix: types

* fix: type

* fix: downstream types

* chore: snaps

* chore: var fallback

* chore: bump version

* feat: loosen account requirement on estimateGas; tighten prepareTransactionResult type

* docs: update custom client example (#1492)

* refactor: retry & fallback errors

* refactor: wallet client retries

* fix: client extensions w/ chain formatters

* tests: update

* chore: upgrade ts

* chore: lockfile

* chore: merge conflicts

* feat: deposit transaction (op stack) (#1479)

* chore: var fallback

* feat: deposit transaction

* docs

* refactor: api, docs, etc

* refactor: anvil

* refactor: dump op addresses

* tweaks

* feat: prepareDepositTransaction

* feat: mint

* docs: prepare

* refactor: prepare -> build

* feat: extractEventLogs

* docs: remove

* docs: parseEventLogs

* feat: serializer

* refactor

* feat: parsers

* feat: source hash computation

* feat: fromOpaqueData

* feat: compute l2 hashes

* docs: deposit guide

* fix: waitForTxnReceipt

* docs: deposit guide

* chore: example

* chore: update examples

* chore: update snaps

* chore: lint

* update

* update

* chore: update snaps

---------

Co-authored-by: Tom Meagher <tom@meagher.co>

* feat: spread fallback opts

* chore: publish package

* fix: default types

* chore: version package

* chore: export type

* chore: version package

* chore: export types

* chore: publish package

* chore: upgrade playwright

* feat: export promise utils

* chore: publish package

* chore: publish package

* chore: version package

* docs: Add missing params for verifyMessage and verifyTypedData (#1574)

* feat: export getProof from root and from actions (#1571)

* feat: export getProof from root and from actions

* Create dry-bananas-smile.md

---------

Co-authored-by: jxom <jakemoxey@gmail.com>

* chore: update snapshots

* chore: update

* fix: txn receipt

* docs: update migration guide

* docs: ethers migration

* feat: add missing exports (#1583)

* fix: add missing exports

* chore: add changeset

* chore: rename fromOpaqueData

* chore: version package

* feat: opstack withdrawal (#1565)

* feat: initiateWithdrawal

* docs

* feat: buildInitiateWithdrawal

* feat: getSecondsToNextL2Output

* feat: utils

* docs: sidebar

* feat: getWithdrawalHashStorageSlot

* feat: getL2Output

* docs: update withdrawal

* chore: sepolia

* feat: buildProveWithdrawal

* feat: waitForL2Output

* feat: proveWithdrawal

* feat: readyToProve

* docs: dead links

* docs: sidebar

* feat: getTimeToFinalize

* refactor: getWithdrawals

* docs: fix

* docs: update

* feat: waitToFinalize

* feat: finalizeWithdrawal

* feat: getTimeToProve

* chore: period

* refactor

* refactor

* feat: getWithdrawalStatus + rest

* chore: remove example

* chore: clean

* chore: lockfile

* refactor: error type

* feat: estimate actions

* test: remove only

* docs: remove deadlink

* fix: ts 5.0.4 errors

* chore: version

* ci: trigger

* chore: remove changesets from prerelease

* fix: log formatting

* chore: version

* WIP

* chore: add missing type export

* docs: update OP Stack docs in RC CHA-69 (#1612)

* feat: Add more docs to op

* Update site/op-stack/client.md

* Update site/op-stack/client.md

* Apply suggestions from code review

Co-authored-by: jxom  <jakemoxey@gmail.com>

---------

Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jakemoxey@gmail.com>

* chore: format

* fix: simulate types

* fix: test

* chore: version

* chore: tweak

* wip

* chore: version

* wip

* wip

* wip

* wip

* wip

* update

* wip

* wip

* chore: delete vitepress

* chore: update

* update docs

* delete changeset

* rewrite

---------

Co-authored-by: Tom Meagher <tom@meagher.co>
Co-authored-by: Will Cory <willcory10@gmail.com>
Co-authored-by: Omar <omaraziz.dev@proton.me>
Co-authored-by: Vitor Marthendal Nunes <marthendalnunes@gmail.com>
Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jxom@users.noreply.github.com>

* feat: vocs (#1675)

* chore: canary

* chore: export types

* chore: remove unecessary type export

* chore: export version

* refactor: contract types

* chore: export

* refactor: generics

* refactor: contract types

* refactor: multicall types

* test: multicall types

* refactor: multicall response

* test: multicall types

* refactor: multicall results

* chore: export type

* chore: prettify type

* refactor: contract types

* refactor: contract function generics

* refactor: contract function args generic tweaks

* chore: prettify chain

* chore: update changeset

* chore: remove version export

* chore: restore version

* fix: type error

* refactor: abi types

* wip: types

* wip: types

* chore: fix type test

* chore: checkpoint

* fix: explicit undefined

* chore: ignore changes

* chore: export types

* refactor: simulate contract return type

* fix: transport generic

* refactor: eventName generics

* refactor: simplify poll options

* refactor: consolidate poll options

* fix: test

* chore: update snapshots

* ci: update version in snapshot

* ci: tweak

* chore: export abis

* chore: update snapshot

* chore: update snap

* chore: fix imports

* chore: enter alpha

* chore: update

* chore: add timeout

* chore: types

* chore: bump version

* chore: export types

* fix: type exports

* chore: bump version

* chore: clean up write contract types

* chore: bump version

* chore: update multicall type

* chore: bump version

* chore: version

* chore: export type

* chore: version

* chore: version

* ci: bump release timeout

* chore: version

* feat: refactor getContract

* docs: getContract

* chore: remove entrypoints

* chore: remove note

* fix

* fix: simulateContract account type

* fix

* chore: version

* refactor: chain

* chore: bump abitype

* chore: bump version

* chore: snaps

* docs: chains

* chore: snaps

* chore: snaps

* chore: bump version

* chore: add missing type

* chore: bump version

* test: update snaps

* chore: prettify chain

* refactor: defineChain

* refactor: defineChain type

* chore: remove

* docs: defineChain

* fix: downstream type error

* chore: beta

* chore: remove deprecated things

* docs: chains

* chore: update snaps

* refactor: contract function types

* chore: bump version

* feat: opstack (fees/gas actions) (#1469)

* wip: opstack init

* feat: total gas

* feat: total gas

* feat: imports

* docs: migration guide

* feat: exports

* docs: celo

* docs

* feat: fees

* feat: contract fee/gas estimation

* feat: exports

* feat: exports

* chore: docspath

* chore: update snaps

* docs: address

* docs: sidebar

* tests: fix

* fix: exports

* docs: fix links

* docs: typos

* Update site/docs/op-stack/client.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Fee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Gas.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractTotalFee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Gas.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* Update site/docs/op-stack/estimateContractL1Fee.md

Co-authored-by: Will Cory <willcory10@gmail.com>

* chore: export

* chore: pr review

* docs: updatE

---------

Co-authored-by: Will Cory <willcory10@gmail.com>

* chore: bump version

* docs: op stack

* docs: dead links

* refactor: rename

* chore: version

* fix: typo

* chore: merge

* refactor: opstack

* fix: types

* fix: type

* fix: downstream types

* chore: snaps

* chore: var fallback

* chore: bump version

* feat: loosen account requirement on estimateGas; tighten prepareTransactionResult type

* docs: update custom client example (#1492)

* refactor: retry & fallback errors

* refactor: wallet client retries

* fix: client extensions w/ chain formatters

* tests: update

* chore: upgrade ts

* chore: lockfile

* chore: merge conflicts

* feat: deposit transaction (op stack) (#1479)

* chore: var fallback

* feat: deposit transaction

* docs

* refactor: api, docs, etc

* refactor: anvil

* refactor: dump op addresses

* tweaks

* feat: prepareDepositTransaction

* feat: mint

* docs: prepare

* refactor: prepare -> build

* feat: extractEventLogs

* docs: remove

* docs: parseEventLogs

* feat: serializer

* refactor

* feat: parsers

* feat: source hash computation

* feat: fromOpaqueData

* feat: compute l2 hashes

* docs: deposit guide

* fix: waitForTxnReceipt

* docs: deposit guide

* chore: example

* chore: update examples

* chore: update snaps

* chore: lint

* update

* update

* chore: update snaps

---------

Co-authored-by: Tom Meagher <tom@meagher.co>

* feat: spread fallback opts

* chore: publish package

* fix: default types

* chore: version package

* chore: export type

* chore: version package

* chore: export types

* chore: publish package

* chore: upgrade playwright

* feat: export promise utils

* chore: publish package

* chore: publish package

* chore: version package

* docs: Add missing params for verifyMessage and verifyTypedData (#1574)

* feat: export getProof from root and from actions (#1571)

* feat: export getProof from root and from actions

* Create dry-bananas-smile.md

---------

Co-authored-by: jxom <jakemoxey@gmail.com>

* chore: update snapshots

* chore: update

* fix: txn receipt

* docs: update migration guide

* docs: ethers migration

* feat: add missing exports (#1583)

* fix: add missing exports

* chore: add changeset

* chore: rename fromOpaqueData

* chore: version package

* feat: opstack withdrawal (#1565)

* feat: initiateWithdrawal

* docs

* feat: buildInitiateWithdrawal

* feat: getSecondsToNextL2Output

* feat: utils

* docs: sidebar

* feat: getWithdrawalHashStorageSlot

* feat: getL2Output

* docs: update withdrawal

* chore: sepolia

* feat: buildProveWithdrawal

* feat: waitForL2Output

* feat: proveWithdrawal

* feat: readyToProve

* docs: dead links

* docs: sidebar

* feat: getTimeToFinalize

* refactor: getWithdrawals

* docs: fix

* docs: update

* feat: waitToFinalize

* feat: finalizeWithdrawal

* feat: getTimeToProve

* chore: period

* refactor

* refactor

* feat: getWithdrawalStatus + rest

* chore: remove example

* chore: clean

* chore: lockfile

* refactor: error type

* feat: estimate actions

* test: remove only

* docs: remove deadlink

* fix: ts 5.0.4 errors

* chore: version

* ci: trigger

* chore: remove changesets from prerelease

* fix: log formatting

* chore: version

* WIP

* chore: add missing type export

* docs: update OP Stack docs in RC CHA-69 (#1612)

* feat: Add more docs to op

* Update site/op-stack/client.md

* Update site/op-stack/client.md

* Apply suggestions from code review

Co-authored-by: jxom  <jakemoxey@gmail.com>

---------

Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jakemoxey@gmail.com>

* chore: format

* fix: simulate types

* fix: test

* chore: version

* chore: tweak

* wip

* chore: version

* wip

* wip

* wip

* wip

* wip

* update

* wip

* wip

* chore: delete vitepress

* chore: update

* update docs

* delete changeset

* rewrite

---------

Co-authored-by: Tom Meagher <tom@meagher.co>
Co-authored-by: Will Cory <willcory10@gmail.com>
Co-authored-by: Omar <omaraziz.dev@proton.me>
Co-authored-by: Vitor Marthendal Nunes <marthendalnunes@gmail.com>
Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jxom@users.noreply.github.com>

* Added documentation.

* fix

* chore: migrate vocs

* refactor

* docs

* Tests fix, docs udpate.

* Update settings.json

* Create shaggy-ravens-kiss.md

* Update shaggy-ravens-kiss.md

* Update zksync.mdx

---------

Co-authored-by: moxey.eth <jakemoxey@gmail.com>
Co-authored-by: Tom Meagher <tom@meagher.co>
Co-authored-by: Will Cory <willcory10@gmail.com>
Co-authored-by: Omar <omaraziz.dev@proton.me>
Co-authored-by: Vitor Marthendal Nunes <marthendalnunes@gmail.com>
Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jxom@users.noreply.github.com>
  • Loading branch information
8 people committed Jan 28, 2024
1 parent 3f503f5 commit 09a4d9e
Show file tree
Hide file tree
Showing 53 changed files with 3,231 additions and 355 deletions.
5 changes: 5 additions & 0 deletions .changeset/shaggy-ravens-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": minor
---

Added zkSync Extensions.
2 changes: 1 addition & 1 deletion site/pages/op-stack/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const publicClient = createPublicClient({
const l1Gas = await publicClient.estimateL1Gas({/* ... */})
```

## Decorators
## Extensions

### `walletActionsL1`

Expand Down
74 changes: 74 additions & 0 deletions site/pages/zksync.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
description: Getting started with the zkSync in Viem
---

# Getting started with zkSync

Viem provides first-class support for the [zkSync](https://zksync.io) chain.

zkSync is a Layer-2 protocol that scales Ethereum with cutting-edge ZK tech.

## Quick Start

### 1. Set up your Client & Transport

Firstly, set up your [Client](/docs/clients/intro) with a desired [Transport](/docs/clients/intro) & [zkSync Chain](./zksync/chains.md) and extend it with zkSync EIP712 actions.

```ts twoslash
import 'viem/window'
// ---cut---
import { createWalletClient, custom } from 'viem'
import { zkSync } from 'viem/chains'
import { eip712WalletActions } from 'viem/zksync'

const walletClient = createWalletClient({ // [!code hl]
chain: zkSync, // [!code hl]
transport: custom(window.ethereum!), // [!code hl]
}).extend(eip712WalletActions()) // [!code hl]
```

### 2. Use Actions

Now that you have a Client set up, you can [send a transaction](./zksync/actions/sendTransaction.md) on zkSync using a [paymaster](https://docs.zksync.io/build/developer-reference/account-abstraction.html#paymasters)!

```ts twoslash
import 'viem/window'
import { createWalletClient, custom } from 'viem'
import { zkSync } from 'viem/chains'
import { eip712WalletActions } from 'viem/zksync'

const walletClient = createWalletClient({
chain: zkSync,
transport: custom(window.ethereum!),
}).extend(eip712WalletActions())
// ---cut---
const hash = await walletClient.sendTransaction({
account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n,
paymaster: '0xFD9aE5ebB0F6656f4b77a0E99dCbc5138d54b0BA',
paymasterInput: '0x123abc...'
})
```

...and even write to contracts:

```ts twoslash
import 'viem/window'
import { createWalletClient, custom, parseAbi } from 'viem'
import { zkSync } from 'viem/chains'
import { eip712WalletActions } from 'viem/zksync'

const walletClient = createWalletClient({
account: '0x',
chain: zkSync,
transport: custom(window.ethereum!),
}).extend(eip712WalletActions())
// ---cut---
const hash = await walletClient.writeContract({
address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),
functionName: 'mint',
args: [69420],
})
```
291 changes: 291 additions & 0 deletions site/pages/zksync/actions/sendTransaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
---
description: Creates, signs, and sends a new transaction to the network, with EIP712 transaction support.
---

# sendTransaction

Creates, signs, and sends a new transaction to the network, with EIP712 transaction support.

## Usage

:::code-group

```ts [example.ts]
import { account, walletClient } from './config'

const hash = await walletClient.sendTransaction({ // [!code focus:99]
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
// '0x...'
```

```ts [config.ts]
import { createWalletClient, custom } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { zksync } from 'viem/chains'
import { eip712Actions } from 'viem/zksync'

export const walletClient = createWalletClient({
chain: zksync,
transport: custom(window.ethereum)
}).extend(eip712WalletActions())

// JSON-RPC Account
export const [account] = await walletClient.getAddresses()
// Local Account
export const account = privateKeyToAccount(...)
```

:::

### Account Hoisting

If you do not wish to pass an `account` to every `sendTransaction`, you can also hoist the Account on the Wallet Client (see `config.ts`).

[Learn more](/docs/clients/wallet#account).

:::code-group

```ts [example.ts]
import { walletClient } from './config'

const hash = await walletClient.sendTransaction({ // [!code focus:99]
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
// '0x...'
```

```ts [config.ts (JSON-RPC Account)]
import { createWalletClient, custom } from 'viem'
import { eip712Actions } from 'viem/zksync'

// Retrieve Account from an EIP-712 Provider. // [!code focus]
const [account] = await window.ethereum.request({ // [!code focus]
method: 'eth_requestAccounts' // [!code focus]
}) // [!code focus]

export const walletClient = createWalletClient({
account,
transport: custom(window.ethereum) // [!code focus]
}).extend(eip712WalletActions())
```

```ts [config.ts (Local Account)]
import { createWalletClient, custom } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { eip712Actions } from 'viem/zksync'

export const walletClient = createWalletClient({
account: privateKeyToAccount('0x...'), // [!code focus]
transport: custom(window.ethereum)
}).extend(eip712WalletActions())
```

:::

## Returns

[`Hash`](/docs/glossary/types#hash)

The [Transaction](/docs/glossary/terms#transaction) hash.

## Parameters

### account

- **Type:** `Account | Address`

The Account to send the transaction from.

Accepts a [JSON-RPC Account](/docs/clients/wallet#json-rpc-accounts) or [Local Account (Private Key, etc)](/docs/clients/wallet#local-accounts-private-key-mnemonic-etc).

```ts
const hash = await walletClient.sendTransaction({
account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', // [!code focus]
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
```

### to

- **Type:** `0x${string}`

The transaction recipient or contract address.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', // [!code focus]
value: 1000000000000000000n,
nonce: 69
})
```

### accessList (optional)

- **Type:** [`AccessList`](/docs/glossary/types#accesslist)

The access list.

```ts
const hash = await walletClient.sendTransaction({
accessList: [ // [!code focus:6]
{
address: '0x1',
storageKeys: ['0x1'],
},
],
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
})
```

### chain (optional)

- **Type:** [`Chain`](/docs/glossary/types#chain)
- **Default:** `walletClient.chain`

The target chain. If there is a mismatch between the wallet's current chain & the target chain, an error will be thrown.

The chain is also used to infer its request type (e.g. the Celo chain has a `gatewayFee` that you can pass through to `sendTransaction`).

```ts
import { zksync } from 'viem/chains' // [!code focus]
const hash = await walletClient.sendTransaction({
chain: zksync, // [!code focus]
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
```

### data (optional)

- **Type:** `0x${string}`

A contract hashed method call with encoded args.

```ts
const hash = await walletClient.sendTransaction({
data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', // [!code focus]
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
```

### gasPrice (optional)

- **Type:** `bigint`

The price (in wei) to pay per gas. Only applies to [Legacy Transactions](/docs/glossary/terms#legacy-transaction).

```ts
const hash = await walletClient.sendTransaction({
account,
gasPrice: parseGwei('20'), // [!code focus]
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n
})
```

### nonce (optional)

- **Type:** `number`

Unique number identifying this transaction.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: 1000000000000000000n,
nonce: 69 // [!code focus]
})
```

### value (optional)

- **Type:** `bigint`

Value in wei sent with this transaction.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
value: parseEther('1'), // [!code focus]
nonce: 69
})
```

### gasPerPubdata (optional)

- **Type:** `bigint`

The amount of gas for publishing one byte of data on Ethereum.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
gasPerPubdata: 50000, // [!code focus]
nonce: 69,
value: 1000000000000000000n
})
```

### factoryDeps (optional)

- **Type:** `[0x${string}]`

Contains bytecode of the deployed contract.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
factoryDeps: ['0xcde...'], // [!code focus]
nonce: 69,
value: 1000000000000000000n
})
```

### paymaster (optional)

- **Type:** `Account | Address`

Address of the paymaster account that will pay the fees. The `paymasterInput` field is required with this one.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
paymaster: '0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021', // [!code focus]
paymasterInput: '0x8c5a...' // [!code focus]
nonce: 69,
value: 1000000000000000000n
})
```

### paymasterInput (optional)

- **Type:** `0x${string}`

Input data to the paymaster. The `paymaster` field is required with this one.

```ts
const hash = await walletClient.sendTransaction({
account,
to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
paymaster: '0x4B5DF730c2e6b28E17013A1485E5d9BC41Efe021', // [!code focus]
paymasterInput: '0x8c5a...' // [!code focus]
nonce: 69,
value: 1000000000000000000n
})
```
Loading

1 comment on commit 09a4d9e

@vercel
Copy link

@vercel vercel bot commented on 09a4d9e Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.