You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pvysmz68u 2adf5d5408
new version
4 months ago
..
Abi new version 4 months ago
AbiConstructor new version 4 months ago
AbiError new version 4 months ago
AbiEvent new version 4 months ago
AbiFunction new version 4 months ago
AbiItem new version 4 months ago
AbiParameters new version 4 months ago
AccessList new version 4 months ago
AccountProof new version 4 months ago
Address new version 4 months ago
AesGcm new version 4 months ago
Authorization new version 4 months ago
Base58 new version 4 months ago
Base64 new version 4 months ago
BinaryStateTree new version 4 months ago
Blobs new version 4 months ago
Block new version 4 months ago
BlockOverrides new version 4 months ago
Bloom new version 4 months ago
Bls new version 4 months ago
BlsPoint new version 4 months ago
Bytes new version 4 months ago
Caches new version 4 months ago
ContractAddress new version 4 months ago
Ed25519 new version 4 months ago
Ens new version 4 months ago
Errors new version 4 months ago
Fee new version 4 months ago
Filter new version 4 months ago
Hash new version 4 months ago
HdKey new version 4 months ago
Hex new version 4 months ago
Json new version 4 months ago
Keystore new version 4 months ago
Kzg new version 4 months ago
Log new version 4 months ago
Mnemonic new version 4 months ago
P256 new version 4 months ago
PersonalMessage new version 4 months ago
Provider new version 4 months ago
PublicKey new version 4 months ago
Rlp new version 4 months ago
RpcRequest new version 4 months ago
RpcResponse new version 4 months ago
RpcSchema new version 4 months ago
RpcTransport new version 4 months ago
Secp256k1 new version 4 months ago
Signature new version 4 months ago
Siwe new version 4 months ago
Solidity new version 4 months ago
StateOverrides new version 4 months ago
Transaction new version 4 months ago
TransactionEnvelope new version 4 months ago
TransactionEnvelopeEip1559 new version 4 months ago
TransactionEnvelopeEip2930 new version 4 months ago
TransactionEnvelopeEip4844 new version 4 months ago
TransactionEnvelopeEip7702 new version 4 months ago
TransactionEnvelopeLegacy new version 4 months ago
TransactionReceipt new version 4 months ago
TransactionRequest new version 4 months ago
TypedData new version 4 months ago
ValidatorData new version 4 months ago
Value new version 4 months ago
WebAuthnP256 new version 4 months ago
WebCryptoP256 new version 4 months ago
Withdrawal new version 4 months ago
X25519 new version 4 months ago
_cjs new version 4 months ago
_esm new version 4 months ago
_types new version 4 months ago
core new version 4 months ago
erc4337 new version 4 months ago
erc6492 new version 4 months ago
erc8010 new version 4 months ago
index.docs new version 4 months ago
trusted-setups new version 4 months ago
window new version 4 months ago
CHANGELOG.md new version 4 months ago
LICENSE new version 4 months ago
README.md new version 4 months ago
index.docs.ts new version 4 months ago
index.ts new version 4 months ago
package.json new version 4 months ago
tsdoc.json new version 4 months ago
version.ts new version 4 months ago

README.md


ox logo

Version MIT License Code coverage

Overview

Ox (⦻) is the foundation of robust Ethereum software written in TypeScript. It is an Ethereum Standard Library that provides a set of lightweight, performant, and type-safe TypeScript modules for Ethereum.

It offers core utilities & types for primitives such as: ABIs, Addresses, Blocks, Bytes, ECDSA, Hex, JSON-RPC, RLP, Signing & Signatures, Transaction Envelopes, and more.

As an unopinionated Standard Library, it is designed to be used by higher-level consumers (such as Viem, Tevm, or their alternatives) to provide their own opinionated interfaces, and/or when reaching for low-level primitives may be needed without buying into a Client Abstraction stack (Viem, Ethers, Web3.js, etc).

Documentation

Head to the documentation to read and learn more about Ox.

Example Usage

The example below demonstrates how to construct, sign, and broadcast a transaction envelope using Ox:

import { Provider, Secp256k1, TransactionEnvelopeEip1559, Value } from 'ox'
 
// 1. Construct a transaction envelope.
const envelope = TransactionEnvelopeEip1559.from({
  chainId: 1,
  gas: 21000n,
  nonce: 0n,
  maxFeePerGas: Value.fromGwei('10'),
  maxPriorityFeePerGas: Value.fromGwei('1'),
  to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
  value: Value.fromEther('1'),
})
 
// 2. Get the signing payload for the envelope.
const payload = TransactionEnvelopeEip1559.getSignPayload(envelope) 
 
// 3. Sign the payload with your private key using secp256k1.
const signature = Secp256k1.sign({ payload, privateKey: '0x...' })

// 4. Serialize the envelope with the signature.
const serialized = TransactionEnvelopeEip1559.serialize(envelope, { signature })

// 5. Broadcast the envelope to the network.
const provider = Provider.from(window.ethereum)
const hash = await provider.request({
  method: 'eth_sendRawTransaction',
  params: [serialized],
})

[!NOTE]
Ox's APIs are purposely stateless, unopinionated, and verbose. The example above can definitely be achieved in a few lines of code in a more concise manner, however, the goal is for higher-level abstractions (Viem, etc) built on top of Ox to handle this for you.

Community

Check out the following places for more Ox-related content:

Support