From 0356db1faea15517af5f99166c7203015ea89625 Mon Sep 17 00:00:00 2001 From: Waylon Jepsen <57912727+0xJepsen@users.noreply.github.com> Date: Tue, 21 Mar 2023 12:15:41 -0600 Subject: [PATCH] Contracts chapter (#2281) --- book/SUMMARY.md | 40 ++++++++++--------- book/contracts/abigen.md | 5 +++ book/contracts/compile.md | 5 +++ book/contracts/contracts.md | 29 ++++++++++++++ book/contracts/creating-instances.md | 5 +++ book/contracts/deploy-anvil.md | 5 +++ .../contracts/deploy-from-abi-and-bytecode.md | 5 +++ book/contracts/doploy-moonbeam.md | 5 +++ book/contracts/events-with-meta.md | 5 +++ book/contracts/events.md | 5 +++ book/contracts/methods.md | 5 +++ 11 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 book/contracts/abigen.md create mode 100644 book/contracts/compile.md create mode 100644 book/contracts/contracts.md create mode 100644 book/contracts/creating-instances.md create mode 100644 book/contracts/deploy-anvil.md create mode 100644 book/contracts/deploy-from-abi-and-bytecode.md create mode 100644 book/contracts/doploy-moonbeam.md create mode 100644 book/contracts/events-with-meta.md create mode 100644 book/contracts/events.md create mode 100644 book/contracts/methods.md diff --git a/book/SUMMARY.md b/book/SUMMARY.md index 1998ee06..0bf0bae0 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -1,11 +1,13 @@ # Summary # Getting started - - [Intro](./getting-started/intro.md) - - [Start a new project](./getting-started/start_a_new_project.md) - - [Connect to an Ethereum node](./getting-started/connect_to_an_ethereum_node.md) + +- [Intro](./getting-started/intro.md) +- [Start a new project](./getting-started/start_a_new_project.md) +- [Connect to an Ethereum node](./getting-started/connect_to_an_ethereum_node.md) # Reference guide + - [Providers](./providers/providers.md) - [Http](./providers/http.md) - [WebSocket](./providers/ws.md) @@ -26,16 +28,16 @@ - [Signer](./middleware/signer.md) - [Time lag]() - [Transformer]() -- [Contracts]() - - [Abigen]() - - [Compile]() - - [Creating Instances]() - - [Deploy Anvil]() - - [Deploy from ABI and bytecode]() - - [Deploy Moonbeam]() - - [Events]() - - [Events with meta]() - - [Methods]() +- [Contracts](./contracts/contracts.md) + - [Abigen](./contracts/abigen.md) + - [Compile](./contracts/compile.md) + - [Creating Instances](./contracts/creating-instances.md) + - [Deploy Anvil](./contracts/deploy-anvil.md) + - [Deploy from ABI and bytecode](./contracts/deploy-from-abi-and-bytecode.md) + - [Deploy Moonbeam](./contracts/doploy-moonbeam.md) + - [Events](./contracts/events.md) + - [Events with meta](./contracts/events-with-meta.md) + - [Methods](contracts/methods.md) - [Events]() - [Logs and filtering]() - [Solidity topics]() @@ -56,7 +58,7 @@ - [Create typed transaction]() - [Decode input]() - [EIP-1559]() - - [ENS]() + - [ENS]() - [Estimate gas]() - [Get gas price]() - [Get gas price USD]() @@ -78,13 +80,13 @@ - [Trezor]() - [Yubi]() - [Big numbers](./big-numbers/intro.md) - - [Comparison and equivalence](./big-numbers/comparison-and-equivalence.md) + - [Comparison and equivalence](./big-numbers/comparison-and-equivalence.md) - [Conversion](./big-numbers/conversion.md) - [Creating Instances](./big-numbers/creating_instances.md) - [Math operations](./big-numbers/math-operations.md) - [Utilities](./big-numbers/utilities.md) - [Anvil]() - - [Boot anvil]() - - [Deploy contracts]() - - [Fork]() - - [Testing]() + - [Boot anvil]() + - [Deploy contracts]() + - [Fork]() + - [Testing]() diff --git a/book/contracts/abigen.md b/book/contracts/abigen.md new file mode 100644 index 00000000..b93306d6 --- /dev/null +++ b/book/contracts/abigen.md @@ -0,0 +1,5 @@ +# Abigen + +```rust +{{#include ../../examples/contracts/examples/abigen.rs}} +``` diff --git a/book/contracts/compile.md b/book/contracts/compile.md new file mode 100644 index 00000000..80708c27 --- /dev/null +++ b/book/contracts/compile.md @@ -0,0 +1,5 @@ +# Compile + +```rust +{{#include ../../examples/contracts/examples/compile.rs}} +``` diff --git a/book/contracts/contracts.md b/book/contracts/contracts.md new file mode 100644 index 00000000..dc490f19 --- /dev/null +++ b/book/contracts/contracts.md @@ -0,0 +1,29 @@ +# Contracts + +In ethers-rs, contracts are a way to interact with smart contracts on the Ethereum blockchain through rust bindings, which serve as a robust rust API to these objects. + +The ethers-contracts module includes the following features: + +- [Abigen](): A module for generating Rust code from Solidity contracts. +- [Compile](): A module for compiling Solidity contracts into bytecode and ABI files. +- [Creating Instances](): A module for creating instances of smart contracts. +- [Deploy Anvil](): A module for deploying smart contracts on the Anvil network. +- [Deploy from ABI and bytecode](): A module for deploying smart contracts from their ABI and bytecode files. +- [Deploy Moonbeam](): A module for deploying smart contracts on the Moonbeam network. +- [Events](): A module for listening to smart contract events. +- [Events with Meta](): A module for listening to smart contract events with metadata. +- [Methods](): A module for calling smart contract methods. + +The ethers-contracts module provides a convenient way to work with Ethereum smart contracts in Rust. With this module, you can easily create instances of smart contracts, deploy them to the network, and interact with their methods and events. + +The Abigen module allows you to generate Rust code from Solidity contracts, which can save you a lot of time and effort when writing Rust code for Ethereum smart contracts. + +The Compile module makes it easy to compile Solidity contracts into bytecode and ABI files, which are required for deploying smart contracts. + +The Deploy Anvil and Deploy Moonbeam modules allow you to deploy smart contracts to specific networks, making it easy to test and deploy your smart contracts on the desired network. + +The Events and Events with Meta modules allow you to listen to smart contract events and retrieve event data, which is essential for building applications that interact with Ethereum smart contracts. + +Finally, the Methods module provides a simple way to call smart contract methods from Rust code, allowing you to interact with smart contracts in a programmatic way. + +Overall, the ethers-contracts module provides a comprehensive set of tools for working with Ethereum smart contracts in Rust, making it an essential tool for Rust developers building decentralized applications on the Ethereum network. diff --git a/book/contracts/creating-instances.md b/book/contracts/creating-instances.md new file mode 100644 index 00000000..635d858b --- /dev/null +++ b/book/contracts/creating-instances.md @@ -0,0 +1,5 @@ +# Creating Instances + +```rust +{{#include ../../examples/contracts/examples/instances.rs}} +``` diff --git a/book/contracts/deploy-anvil.md b/book/contracts/deploy-anvil.md new file mode 100644 index 00000000..721cfdbf --- /dev/null +++ b/book/contracts/deploy-anvil.md @@ -0,0 +1,5 @@ +# Deploy Anvil + +```rust +{{#include ../../examples/contracts/examples/deploy_anvil.rs}} +``` diff --git a/book/contracts/deploy-from-abi-and-bytecode.md b/book/contracts/deploy-from-abi-and-bytecode.md new file mode 100644 index 00000000..650a3d6f --- /dev/null +++ b/book/contracts/deploy-from-abi-and-bytecode.md @@ -0,0 +1,5 @@ +# Deploying a Contract from ABI and Bytecode + +```rust +{{#include ../../examples/contracts/examples/deploy_from_abi_and_bytecode.rs}} +``` diff --git a/book/contracts/doploy-moonbeam.md b/book/contracts/doploy-moonbeam.md new file mode 100644 index 00000000..4bea6cf2 --- /dev/null +++ b/book/contracts/doploy-moonbeam.md @@ -0,0 +1,5 @@ +# Deploy Moonbeam + +```rust +{{#include ../../examples/contracts/examples/deploy_moonbeam.rs}} +``` diff --git a/book/contracts/events-with-meta.md b/book/contracts/events-with-meta.md new file mode 100644 index 00000000..1d4d4f4b --- /dev/null +++ b/book/contracts/events-with-meta.md @@ -0,0 +1,5 @@ +# Events with meta + +```rust +{{#include ../../examples/contracts/examples/events_with_meta.rs}} +``` diff --git a/book/contracts/events.md b/book/contracts/events.md new file mode 100644 index 00000000..0c30117c --- /dev/null +++ b/book/contracts/events.md @@ -0,0 +1,5 @@ +# Events + +```rust +{{#include ../../examples/contracts/examples/events.rs}} +``` diff --git a/book/contracts/methods.md b/book/contracts/methods.md new file mode 100644 index 00000000..5fe1d579 --- /dev/null +++ b/book/contracts/methods.md @@ -0,0 +1,5 @@ +# Methods + +```rust +{{#include ../../examples/contracts/examples/methods.rs}} +```