opensea.rs

opensea.rs is a powerful Rust library and CLI tool designed to interact with the Opensea API and its associated Ethereum smart contracts. This project aims to provide developers with a robust and efficient interface for managing and transacting NFTs on the Opensea marketplace using the Rust programming language.

Key Features

opensea.rs offers a range of features tailored for developers:

  • Opensea API: Provides comprehensive bindings to interact with the Opensea API.
  • Opensea Types: Includes essential types such as Orders, enabling seamless integration with Opensea's orderbook.
  • Contract Clients: Supports interactions with ERC721 and ERC1155 contracts, allowing users to fill sell orders and more.
  • CLI Tool: Features a command-line interface for various operations, including deploying contracts, querying prices, and purchasing NFTs. The CLI also supports Flashbots integration for private and efficient transactions.

CLI Usage

The CLI tool is versatile and user-friendly. To access the top-level help menu, run:

cargo r -- --help

This command provides information on available subcommands such as buying NFTs, deploying contracts, and querying prices. Each subcommand comes with its own help menu, accessible via:

opensea-cli <subcommand> --help

Buying NFTs

The CLI allows for purchasing NFTs with detailed options for ERC1155 and ERC721 tokens. Here is an example command for buying ERC1155 NFTs using Flashbots:

cargo run buy \
    --nft.erc1155 \
    --nft.address "0xTheNFTAddress" \
    --nft.ids 1 --nft.ids 2 --nft.ids 3 \
    --eth.private_key "0xMyPrivateKey" \
    --eth.url http://localhost:8545 \
    --flashbots.bribe 1000000000000000000 \
    --flashbots.bribe_receiver 0xYourBriberContract

Flashbots Integration

The tool supports Flashbots, allowing transactions to be included in Flashbots bundles, ensuring efficient and private transaction execution. If Flashbots parameters are omitted, transactions are submitted via the public mempool.

Development and Testing

opensea.rs is built using the stable Rust toolchain. Developers can install Rust by running:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Building and Testing

The following commands are available for building and testing the project:

cargo check
cargo test
cargo doc --open
cargo build [--release]

Running Ignored Tests

To run ignored tests, follow these steps:

  1. Create a hardhat.config.js file with the following configuration:
export default {
  networks: {
    hardhat: {
      forking: {
        url: "https://eth-mainnet.alchemyapi.io/v2/<YOUR API KEY>",
        blockNumber: 13037331,
      },
      hardfork: "london",
    },
  },
}
  1. Run the ignored tests with:
cargo test --ignored

Feature Set

The project currently supports the following features, with more in development:

  • Opensea API and Types
  • Contract Clients for ERC721 and ERC1155
  • CLI Operations:
    • Flashbots contract deployment
    • Price querying
    • NFT purchasing
    • Planned support for sniping drops

Similar Projects