Complete Ethereum and Celo wallet implementation and utilities in Rust

Overview

ethers.rs

Complete Ethereum and Celo wallet implementation and utilities in Rust

Github Actions Telegram Chat Crates.io

Documentation

Extensive documentation and examples are available here.

Alternatively, you may clone the repository and run cd ethers/ && cargo doc --open

You can also run any of the examples by executing: cargo run -p ethers --example

Add ethers-rs to your repository

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs" }

Running the tests

Tests require the following installed:

  1. solc. We also recommend using solc-select for more flexibility.
  2. ganache-cli

In addition, it is recommended that you set the ETHERSCAN_API_KEY environment variable for the abigen via Etherscan tests. You can get one here.

EVM-compatible chains support

There are many chains live which are Ethereum JSON-RPC & EVM compatible, but do not yet have support for EIP-2718 Typed Transactions. This means that transactions submitted to them by default in ethers-rs will have invalid serialization. To address that, you must use the legacy feature flag:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["legacy"] }

Polygon support

There is abigen support for Polygon and the Mumbai test network. It is recommended that you set the POLYGONSCAN_API_KEY environment variable. You can get one here.

Avalanche support

There is abigen support for Avalanche and the Fuji test network. It is recommended that you set the SNOWTRACE_API_KEY environment variable. You can get one here.

Celo Support

Celo support is turned on via the feature-flag celo:

[dependencies]

ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["celo"] }

Celo's transactions differ from Ethereum transactions by including 3 new fields:

  • fee_currency: The currency fees are paid in (None for CELO, otherwise it's an Address)
  • gateway_fee_recipient: The address of the fee recipient (None for no gateway fee paid)
  • gateway_fee: Gateway fee amount (None for no gateway fee paid)

The feature flag enables these additional fields in the transaction request builders and in the transactions which are fetched over JSON-RPC.

Features

  • Ethereum JSON-RPC Client
  • Interacting and deploying smart contracts
  • Type safe smart contract bindings code generation
  • Querying past events
  • Event monitoring as Streams
  • ENS as a first class citizen
  • Celo support
  • Polygon support
  • Avalanche support
  • Websockets / eth_subscribe
  • Hardware Wallet Support
  • Parity APIs (tracing, parity_blockWithReceipts)
  • Geth TxPool API
  • WASM Bindings (see note)
  • FFI Bindings (see note)
  • CLI for common operations

Note on WASM and FFI bindings

You should be able to build a wasm app that uses ethers-rs (see the example for reference). If ethers fails to compile in WASM, please open an issue. There is currently no plan to provide an official JS/TS-accessible library interface. we believe ethers.js serves that need very well.

Similarly, you should be able to build FFI bindings to ethers-rs. If ethers fails to compile in c lib formats, please open an issue. There is currently no plan to provide official FFI bindings, and as ethers-rs is not yet stable 1.0.0, its interface may change significantly between versions.

Getting Help

First, see if the answer to your question can be found in the API documentation. If the answer is not there, try opening an issue with the question.

Join the ethers-rs telegram to chat with the community!

Contributing

Thanks for your help improving the project! We are so happy to have you! We have a contributing guide to help you get involved in the ethers-rs project.

If you make a Pull Request, do not forget to add your changes in the CHANGELOG and ensure your code if properly formatted with cargo +nightly fmt and clippy is happy cargo clippy, you can even try to let clippy fix simple issues itself: cargo +nightly clippy --fix -Z unstable-options

Related Projects

This library would not have been possibly without the great work done in:

A lot of the code was inspired and adapted from them, to a unified and opinionated interface, built with async/await and std futures from the ground up.

Projects using ethers-rs

Comments
  • refactor: typed solc ast

    refactor: typed solc ast

    Motivation

    Working with the Solc AST right now is not super ergonomic and it's making it hard to provide support for library coverage in Foundry, since for that feature we would need to walk out to each call expression node and parse the type name. It's doable currently, but a lot of the nice information in the AST is rolled into other, so it's not super easy or maintanable.

    Solution

    Replace the AST abstraction with more strict types. Each node gets its own type loosely based on https://github.com/OpenZeppelin/solidity-ast which claims to have a wide Solidity version support. I'll also add a Visitor trait with some walk_* helper functions for easier traversal.

    I've opened up this PR because I am currently at an impasse: I've started implementing macros to generate some of the common fields in the different nodes, but we could also use struct composition instead.

    The downside of struct composition is that you have to "reach" and I am having some struggle coming up with nice names. For example, the two most common fields are id and src... we could call these "meta", but then what about the expression meta-fields? If we called them "node", then it's a bit awkward since you'd probably have a lot of code doing things like node.node.id.

    If we called these fields "meta", and the common expression fields "expression", then you'd instead have a lot of code doing expr.expression.

    The downside of macros is that it might be slow to compile, too opaque or too inflexible.

    Thoughts @mattsse @gakonst?

    (Docs + doc comments and so on coming later, this is very much a WIP)

    PR Checklist

    • [ ] Added Tests
    • [ ] Added Documentation
    • [ ] Updated the changelog
    opened by onbjerg 20
  • Support `FixedArray` with larger than 32 elements in `abigen!`

    Support `FixedArray` with larger than 32 elements in `abigen!`

    Is your feature request related to a problem? Please describe. Rust does not implement the Default for [T; N] where N > 32. So if a solidity function has an input parameter with type uint256[40], abigen! can not work well.

    Describe the solution you'd like Introduce a custom trait CustomDefault, which has the same behavior as the Default trait, except the way to initialize an array [T; N]. It simply assumes T: Clone and initializes [T; N] by [T::custom_default(); N]. Then implement Default for solidity structs/inputs by CustomDefault.

    Describe alternatives you've considered

    Alternative 1: Manually implementing the Default trait in the procedure macro.

    Alternative 2: Use a wrapped type for large fixed arrays. Like what you did for Uint8.

    opened by k-huetsch 19
  • derive-eip712: initial implementation of eip712 derive macro

    derive-eip712: initial implementation of eip712 derive macro

    This commit provides an initial implementation for a derive macro to encode typed data according to EIP-712, https://eips.ethereum.org/EIPS/eip-712

    Additionally, this commit introduces a new signer trait method:

        async fn sign_typed_data<T: Eip712 + Send + Sync>(
            &self,
            payload: &T,
        ) -> Result<Signature, Self::Error>;
    

    And implements the new method for each of the signers (wallet, ledger, aws).

    At the moment, derive does not recurse the primary type to find nested Eip712 structs. In the future, a field helper attribute #[eip712] could be used to denote a nested field and handle the proper encoding for the field.

    Motivation

    #16

    Solution

    This implementation is based on the proposed solution in #16 .

    PR Checklist

    • [x] Added Tests
    • [x] Added Documentation
    • [x] Updated the changelog
    opened by Ryanmtate 18
  • Add `ContractCall::call_owned(self)`

    Add `ContractCall::call_owned(self)`

    Motivation

    I was trying to call multiple contracts concurrently by aggregating calls into a vec, so that I can join_all(calls).await them later.

    Since ContractCall::call(&self) takes an immutable reference, compiler prevents future from being created because future references ContractCall, which may not live long enough.

    I’ve tried Box-ing ContractCall, but it didn’t quite work.

    Solution

    Add another method that takes ownership: call_owned(self). That completely solved my problem.

    PR Checklist

    • [ ] Added Tests
    • [x] Added Documentation
    • [ ] Updated the changelog
    opened by TmLev 17
  • feat(solc): yul compilation

    feat(solc): yul compilation

    Motivation

    Currently Foundry and ethers-rs is not capable of compiling Yul sources (https://github.com/gakonst/foundry/issues/759)

    Solution

    Add yul compilation

    opened by alexeuler 15
  • Change artifact naming conventions

    Change artifact naming conventions

    Will address #791

    • [x] Fix downstream issue of ambiguous contract naming
    • [x] Handle collision of artifacts compiled with different version
    • [x] Add convenience methods so the cache can be queried for artifact compile info (optim. runs, comp. version)
    • [ ] ~~Support foundry config file~~

    Currently this changes ProjectCompileOutput::into_artifacts to return dapptools-style contract names. Example:

    Greet.json:Greet

    becomes:

    src/test/Greeter.t.sol:Greet

    This fixes this issue w/o any material changes on the foundry side.

    Internally this does two main things:

    1. Changes how output contract paths are created
    2. Preserves relative paths within the artifacts directory

    #\2 is to be able to re-map artifact paths to source paths. During compilation, source paths are discarded and since artifacts don't carry metadata, there's no clean way to carry them around. Keeping relative paths in the artifacts dir solves this.

    @mattsse let me know if you think #\2 is problematic. The flat structure of the artifacts dir seems unnecessary to me, but I may be missing something.

    We could also add compiler versions to paths to avoid the related collision issue.

    WIP

    opened by lattejed 15
  • eip712 compatibility problem between ethers-js and ethers-rs

    eip712 compatibility problem between ethers-js and ethers-rs

    Version

    ├── ethers v0.5.4 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   ├── ethers-contract v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   ├── ethers-contract-abigen v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   ├── ethers-contract-derive v0.5.3 (proc-macro) (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-contract-abigen v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-derive-eip712 v0.1.0 (proc-macro) (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-providers v0.5.4 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   ├── ethers-middleware v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   ├── ethers-contract v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-providers v0.5.4 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   │   ├── ethers-signers v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │   │   │   ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   ├── ethers-providers v0.5.4 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   ├── ethers-signers v0.5.3 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    │   └── ethers-solc v0.1.0 (https://github.com/gakonst/ethers-rs.git#ec00325a)
    │       ├── ethers-core v0.5.5 (https://github.com/gakonst/ethers-rs.git#ec00325a) (*)
    

    Platform windows 11

    Description use the etheris sign a typed data and then copy the data & signature to rust side, it verified failed

    the js code

    const {Wallet, ethers} = require("ethers");
    const crypto = require('crypto');
    
    async function sign_eip712() {
        const mnemonic = "announce room limb pattern dry unit scale effort smooth jazz weasel alcohol"
        const walletMnemonic = Wallet.fromMnemonic(mnemonic)
    
    
        const domain = {
            name: 'Relationship dApp',
            version: '1',
            chainId: 1,
            verifyingContract: '0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc',
            //salt: 'aBrqX434MenBV2yBhAf5oD7VrqbSLW3p'
        };
    
        const types = {
            Receipt : [
                { name: 'address', type: 'string' },
                { name: 'nonce', type: 'string' },
                { name: 'timestamp', type: 'uint256' }
            ]
        };
    
        const value = {
            address: walletMnemonic.address,
            nonce: crypto.randomBytes(16).toString('base64'),
            timestamp: Math.floor(Date.now() / 1000)
        };
    
        const rawSignature = await walletMnemonic._signTypedData(domain, types, value);
        const signature = ethers.utils.splitSignature(rawSignature);
        console.log(JSON.stringify({
            address: value.address,
            nonce: value.nonce,
            timestamp: value.timestamp,
            r: signature.r,
            s: signature.s,
            v: signature.v
        }));
    }
    
    sign_eip712().then(_ => {})
    
    

    rust code:

    use chrono::{Duration, TimeZone, Utc};
    use ethers::types::U256;
    use ethers::{
        contract::{Eip712, EthAbiType},
        core::types::transaction::eip712::Eip712,
        types::{Address, Signature},
        utils::hex,
    };
    use serde::{Deserialize, Deserializer};
    
    fn deserialize_u256_from_i64<'de, D>(deserializer: D) -> Result<U256, D::Error>
    where
        D: Deserializer<'de>,
    {
        i64::deserialize(deserializer).map(U256::from)
    }
    
    #[derive(Clone, Debug, Deserialize, Eip712, EthAbiType)]
    #[eip712(
        name = "Relationship dApp",
        version = "1",
        chain_id = 1,
        verifying_contract = "0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc"
    )]
    pub struct Receipt {
        pub address: Address,
        pub nonce: String,
        #[serde(deserialize_with = "deserialize_u256_from_i64")]
        pub timestamp: U256,
    }
    
    impl Receipt {
        pub fn is_expired(&self, expired: Duration) -> bool {
            let datetime = Utc.timestamp(self.timestamp.try_into().unwrap(), 0);
            (Utc::now() - datetime) > expired
        }
    
        pub fn verify(&self, signature: &Signature) -> anyhow::Result<()> {
            self.encode_eip712()
                .map_err(anyhow::Error::from)
                .and_then(|receipt_hash| {
                    signature
                        .verify(receipt_hash, self.address)
                        .map_err(anyhow::Error::from)
                })
                .map_err(Into::into)
        }
    }
    
    bug 
    opened by Matrix-Zhang 15
  • revert: Ast Artifact

    revert: Ast Artifact

    Motivation

    This reverts parts of #1943 because that PR did not pass all checks and will likely cause a lot of issues in foundry just because there are a lot of different version-specific variants which are likely not covered.

    My suggesting is:

    1. partially revert #1943 breaking changes with this PR
    2. fix tests first
    3. more tests for all versions
    4. reconsider replacing Ast with SourceUnit

    Since the AST is not of interest in most cases, we ca also handle it similar to Metadata where we just use the Json and add a separate function to deserialize the SourceUnit this makes it less error prone for foundry use case and you can still get the deserialized object via an additional call if you need that.

    wdyt @iFrostizz ?

    Solution

    PR Checklist

    • [ ] Added Tests
    • [ ] Added Documentation
    • [ ] Updated the changelog
    • [ ] Breaking changes
    opened by mattsse 14
  • Ledger sign_tx can not work anymore. always show LedgerError(BadRetcode(BadKeyHandle))

    Ledger sign_tx can not work anymore. always show LedgerError(BadRetcode(BadKeyHandle))

    Version ethers-signers = { version = "0.6.2", features = ["ledger"]} ethers-core = "^0.6"

    cargo tree | grep ethers ├── ethers-core v0.6.3 ├── ethers-signers v0.6.2 │ ├── ethers-core v0.6.3 (*)

    Platform Darwin molindeMacBook-Pro-2.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:01 PDT 2021; root:xnu-8019.41.5~1/RELEASE_ARM64_T6000 arm64

    Description Ledger sign_tx can not work anymore. always show LedgerError(BadRetcode(BadKeyHandle))

    I tried this code:

    pub async fn signs_ledger() -> Result<(),()> {
      let ledger = Ledger::new(HDPath::LedgerLive(0), 1).await;
      match ledger {
        Ok(wallet) => {
          println!("Ledger: {:?}", wallet);
    
          let data = hex::decode("095ea7b30000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488dffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap();
    
          let tx_req = TransactionRequest::new()
            .to("0x2ed7afa17473e17ac59908f088b4371d28585476".parse::<Address>().unwrap())
            .gas(1000000)
            .gas_price(400e9 as u64)
            .nonce(5)
            .data(data)
            .value(ethers_core::utils::parse_ether(100).unwrap())
            .into();
          
          println!("tx_req {:?}", tx_req);
          
          let tx = wallet.sign_tx(&tx_req).await;
          match tx {
            Ok(tx_ret) => println!("txRet {:?}", tx_ret),
            Err(e) => println!("Err {:?}", e),
          }
        },
        Err(e) => {
          println!("ERROR {:?}", e.to_string());
        }
      }
      
      Ok(())
    }
    

    I expected to see this happen:

    Ledger: LedgerEthereum { transport: Mutex { is_locked: false, has_waiters: false }, derivation: LedgerLive(0), chain_id: 1, address: 0x0242e3f6ced3817bd4cbc80b66f59bf2970c157c }
    tx_req Legacy(TransactionRequest { from: None, to: Some(Address(0x2ed7afa17473e17ac59908f088b4371d28585476)), gas: Some(1000000), gas_price: Some(400000000000), value: Some(100000000000000000000), data: Some(Bytes(b"\t^\xa7\xb3\0\0\0\0\0\0\0\0\0\0\0\0z%\rV0\xb4\xcfS\x979\xdf,]\xac\xb4\xc6Y\xf2H\x8d\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")), nonce: Some(5) })
    Err LedgerError(BadRetcode(BadKeyHandle))
    

    Instead, this happened: LedgerError(BadRetcode(BadKeyHandle))

    bug 
    opened by lolieatapple 14
  • rust-analyzer complains on `abigen!`

    rust-analyzer complains on `abigen!`

    Version

    ├── ethers v0.6.2
    │   ├── ethers-contract v0.6.2
    │   │   ├── ethers-contract-abigen v0.6.3
    │   │   │   ├── ethers-core v0.6.3
    │   │   ├── ethers-contract-derive v0.6.3 (proc-macro)
    │   │   │   ├── ethers-contract-abigen v0.6.3
    │   │   │   │   ├── ethers-core v0.6.3
    │   │   │   ├── ethers-core v0.6.3 (*)
    │   │   ├── ethers-core v0.6.3 (*)
    │   │   ├── ethers-providers v0.6.2
    │   │   │   ├── ethers-core v0.6.3 (*)
    │   ├── ethers-core v0.6.3 (*)
    │   ├── ethers-etherscan v0.2.2
    │   │   ├── ethers-core v0.6.3 (*)
    │   ├── ethers-middleware v0.6.2
    │   │   ├── ethers-contract v0.6.2 (*)
    │   │   ├── ethers-core v0.6.3 (*)
    │   │   ├── ethers-etherscan v0.2.2 (*)
    │   │   ├── ethers-providers v0.6.2 (*)
    │   │   ├── ethers-signers v0.6.2
    │   │   │   ├── ethers-core v0.6.3 (*)
    │   ├── ethers-providers v0.6.2 (*)
    │   ├── ethers-signers v0.6.2 (*)
    │   └── ethers-solc v0.1.2
    │       ├── ethers-core v0.6.3 (*)
    

    Platform

    Linux dev 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    

    Description

    Using the abigen macro results in rust-analyzer errors, which in turn make code completion unusable.

    /Cargo.toml

    [package]
    name = "demo"
    version = "0.1.0"
    edition = "2021"
    
    [dependencies]
    ethers = "=0.6.2"
    serde_json = "=1.0.79"
    

    /src/main.rs

    use ethers::prelude::abigen;
    
    abigen!(ERC20, "src/ERC20.json");
    
    fn main() {}
    

    /src/ERC20.json

    [
      {
        "inputs": [
          {
            "internalType": "address",
            "name": "account",
            "type": "address"
          }
        ],
        "name": "balanceOf",
        "outputs": [
          {
            "internalType": "uint256",
            "name": "",
            "type": "uint256"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      }
    ]
    

    The code compiles just fine:

    $ cargo build
        Finished dev [unoptimized + debuginfo] target(s) in 0.10s
    

    But rust-analyzer is not happy:

    image

    Not sure if it's just me though.

    bug 
    opened by xJonathanLEI 14
  • refactor: examples

    refactor: examples

    Motivation

    The examples directory is the first place for developers to onboard quickly on ethers-rs. Anyway the lack of a proper structure makes it difficult to find useful content.

    Solution

    I catched your desire to provide something similar to this ebook repo and started restructuring the entire folder providing:

    1. ToC README in the root dir
    2. Refactor examples by topic
    3. Provide new examples where missing
    4. In another PR create a CI step to export docs in convenient formats

    I'll leave this in DRAFT till completion of the first 3 points. @gakonst @mattsse @prestwich let me know if the ToC is missing some core topics.

    Thank you guys

    PR Checklist

    • [ ] Added Tests
    • [x] Added Documentation
    • [ ] Updated the changelog
    • [ ] Breaking changes
    opened by 0xMelkor 13
  • docs: mock-provider

    docs: mock-provider

    Motivation

    Docs improvement

    Solution

    • [x] Provided examples for the MockProvider
    • [x] Extended the mdbook

    PR Checklist

    • [ ] Added Tests
    • [x] Added Documentation
    • [ ] Updated the changelog
    • [ ] Breaking changes
    opened by 0xMelkor 0
  • chore(deps): bump solang-parser from 0.1.18 to 0.2.1

    chore(deps): bump solang-parser from 0.1.18 to 0.2.1

    Bumps solang-parser from 0.1.18 to 0.2.1.

    Release notes

    Sourced from solang-parser's releases.

    v0.2.0: Berlin

    We are happy to release solang v0.2.0 codenamed Berlin today. Aside from containing many small fixes and improvements, this release marks a milestone towards maturing our Substrate compilation target: Any regressions building up since ink! v3.0 are fixed, most notably the metadata format (shoutout and many thanks to external contributor extraymond) and event topics. Furthermore, we are leaving ink! version 3 behind us, in favor of introducing compatibility with the recent ink! 4 beta release and the latest substrate contract node v0.22.1.

    Added

    • Solana / breaking: The try-catch construct is no longer permitted on Solana, as it never worked. Any CPI error will abort the transaction. seanyoung
    • Solana: Introduce new sub-command solang idl which can be used for generating a Solidity interface file from an Anchor IDL file. This can be used for calling Anchor Contracts on Solana. seanyoung
    • Substrate: Provide specific Substrate builtins via a "substrate" file. The Hash type from ink! is the first ink! specific type made available for Solidity contracts. xermicus
    • Substrate: Introduce the --log-api-return-codes CLI flag, which changes the emitted code to print return codes for seal API calls into the debug buffer. xermicus
    • Introduce function name mangling for overloaded functions and constructors, so that they can be represented properly in the metadata. xermicus

    Changed

    • The Solana target now uses Borsh encoding rather than eth abi encoding. This is aimed at making Solang contracts Anchor compatible. LucasSte
    • Substrate / breaking: Supported node version is now pallet contracts v0.22.1. xermicus
    • Substrate / breaking: Remove the deprecated random builtin. xermicus

    Fixed

    • Whenever possible, the parser does not give up after the first error. salaheldinsoliman
    • Constant expressions are checked for overflow. salaheldinsoliman
    • AddMod and MulMod were broken. This is now fixed. LucasSte
    • Substrate / breaking: Solang is now compatible with ink! version 4 (beta). xermicus
    • Substrate: Switched ABI generation to use official ink! crates, which fixes all remaining metadata regressions. extraymond and xermicus
    • Substrate: Allow constructors to have a name, so that multiple constructors are supported, like in ink!. xermicus
    • All provided examples as well as most of the Solidity code snippets in our documentation are now checked for succesful compilation on the Solang CI. xermicus
    • Substrate: Fix events with topics. The topic hashes generated by Solang contracts are now exactly the same as those generated by ink!.

    ... (truncated)

    Changelog

    Sourced from solang-parser's changelog.

    Changelog

    All notable changes to Solang will be documented here.

    Unreleased

    Changed

    • Overriding the function selector value is now done using the @selector([1, 2, 3, 4]) syntax, and the old syntax selector=hex"12345678" has been removed.
    • 'msg.sender' was not implemented correctly on Solana, and has now been removed. seanyoung

    v0.2.0.0 Berlin

    We are happy to release solang v0.2.0 codenamed Berlin today. Aside from containing many small fixes and improvements, this release marks a milestone towards maturing our Substrate compilation target: any regressions building up since ink! v3.0 are fixed, most notably the metadata format (shoutout and many thanks to external contributor extraymond) and event topics. Furthermore, we are leaving ink! version 3 behind us, in favor of introducing compatibility with the recent ink! 4 beta release and the latest substrate contracts node v0.22.1.

    Added

    • Solana / breaking: The try-catch construct is no longer permitted on Solana, as it never worked. Any CPI error will abort the transaction. seanyoung
    • Solana: Introduce new sub-command solang idl which can be used for generating a Solidity interface file from an Anchor IDL file. This can be used for calling Anchor Contracts on Solana. seanyoung
    • Substrate: Provide specific Substrate builtins via a "substrate" file. The Hash type from ink! is the first ink! specific type made available for Solidity contracts. xermicus
    • Substrate: Introduce the --log-api-return-codes CLI flag, which changes the emitted code to print return codes for seal API calls into the debug buffer. xermicus
    • Introduce function name mangling for overloaded functions and constructors, so that they can be represented properly in the metadata. xermicus

    Changed

    • The Solana target now uses Borsh encoding rather than eth abi encoding. This is aimed at making Solang contracts Anchor compatible. LucasSte
    • Substrate / breaking: Supported node version is now pallet contracts v0.22.1. xermicus
    • Substrate / breaking: Remove the deprecated random builtin. xermicus

    ... (truncated)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies rust 
    opened by dependabot[bot] 0
  • fixed issue#2004 parsing solc verison with trailing newlines

    fixed issue#2004 parsing solc verison with trailing newlines

    fixes #2004

    Need some guidance on creating test(s) and updating docs

    PR Checklist

    • [ ] Added Tests
    • [ ] Added Documentation
    • [ ] Updated the changelog
    • [ ] Breaking changes
    opened by elizabethdinella 0
  • ethers-solc version parsing fails with newline suffix

    ethers-solc version parsing fails with newline suffix

    Version ethers-solc v1.0.2

    Platform Linux ash11 4.15.0-143-generic #147-Ubuntu SMP Wed Apr 14 16:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

    Description Using solc installed from solc-select the version cannot be parsed.

    When parsing the solc version I get the error: SemverError(Error("unexpected end of input while parsing major version number"))

    Running solc --version I get:

    solc, the solidity compiler commandline interface
    Version: 0.8.12+commit.f00d7308.Linux.g++
    
    
    

    After some debugging of this code: https://github.com/gakonst/ethers-rs/blob/master/ethers-solc/src/compile/mod.rs#L684-L697

    I found that solc --version output includes two trailing newlines:

    [src/compile/mod.rs:687] &output = Output {
      status: ExitStatus(
        unix_wait_status(
          0,
        ),
      ),
      stdout: "solc, the solidity compiler commandline interface\nVersion: 0.8.12+commit.f00d7308.Linux.g++\n\n",
      stderr: "",
    }
    [src/compile/mod.rs:689] output.stdout.lines().last() = Some(
      Ok(
        "",
      ),
    )
    

    The last() call evaluates to an empty string causing the version parsing to fail.

    I fixed locally by stripping newlines as follows:

    fn version_from_output(output: Output) -> Result<Version> {
        if output.status.success() {
            let version =
                output.
                stdout.
                lines().
                **filter(|l| !l.as_ref().unwrap().is_empty()).**
                last()
                .ok_or_else(|| SolcError::solc("version not found in solc output"))?
                .map_err(|err| SolcError::msg(format!("Failed to read output: {err}")))?;
            // NOTE: semver doesn't like `+` in g++ in build metadata which is invalid semver
            //dbg!(&version);
            Ok(Version::from_str(&version.trim_start_matches("Version: ").replace(".g++", ".gcc"))?)
        } else {
            Err(SolcError::solc(String::from_utf8_lossy(&output.stderr).to_string()))
        }
    }
    
    bug 
    opened by elizabethdinella 0
  • Make

    Make "ethers-providers::transports::common::Request" public

    Is your feature request related to a problem? Please describe.

    No.

    Describe the solution you'd like

    Please make https://github.com/gakonst/ethers-rs/blob/master/ethers-providers/src/transports/common.rs accessible to external crates. Current workaround is just copying the whole file: https://github.com/x04/nfty-public/blob/21b21f70d755a6af7d6b23c5b34bb1bcda4cff7f/nfty/src/flashbots/jsonrpc.rs

    // NOTE: This module only exists since there is no way to use the data structures
    // in the `ethers-providers/src/transports/common.rs` from another crate.
    

    Describe alternatives you've considered

    Change mod transports to pub mod transports.

    And change the following fields to pub:

    pub struct Request<'a, T> {
        pub id: u64,
        pub jsonrpc: &'a str,
        pub method: &'a str,
        #[serde(skip_serializing_if = "is_zst")]
        pub params: T,
    }
    

    Happy to contribute if it's ok with the maintainers.

    Additional context

    N/A

    opened by gyuho 0
  • Remove EthGasStation tests

    Remove EthGasStation tests

    https://github.com/gakonst/ethers-rs/actions/runs/3816587795/jobs/6492313112

    due to eth gas station EOL

    TODO

    • remove test

    cc @DaniPopes easy pick off

    opened by mattsse 2
Owner
Georgios Konstantopoulos
cto & research partner at paradigm.xyz. mev, layer 2, proof of stake, zkps. we're hiring engineers internally & for the portfolio: georgios at paradigm dot xyz
Georgios Konstantopoulos
A Bitcoin wallet collider that brute forces random wallet addresses written in Rust.

Plutus-Rustus Bitcoin Brute Forcer A Bitcoin wallet collider that brute forces random wallet addresses written in Rust. This is a straight port of Plu

null 46 Dec 23, 2022
HD wallet BIP-32 related key derivation utilities.

HDWallet Docs HD wallet(BIP-32) key derivation utilities. This crate is build upon secp256k1 crate, this crate only provides BIP-32 related features,

jjy 23 Nov 27, 2022
Ethereum (and Ethereum like) indexer using P2P message to fetch blocks and transactions

Ethereum P2P indexer This project is an indexer for Ethereum and Ethereum forks. It takes advantage of the ETH (Ethereum Wire Protocol) to fetch block

null 5 Nov 10, 2023
Open source Rust implementation of the Witnet decentralized oracle protocol, including full node and wallet backend 👁️🦀

witnet-rust is an open source implementation of the Witnet Decentralized Oracle Network protocol written in Rust. Components witnet-rust implements ma

The Witnet Project 155 Nov 21, 2022
⋰·⋰ Feeless is a Nano cryptocurrency node, wallet, tools, and Rust crate.

⋰·⋰ Feeless What is Feeless? Feeless is a Nano cryptocurrency node, wallet, tools, and Rust crate. This is not the official project for Nano, only an

null 127 Dec 5, 2022
Core Rust-C FFI for Stackmate Wallet.

STACKMATE-CORE A Rust-C FFI library exposing composite functionality from rust-bitcoin & bdk; to create cross-platform descriptor wallets. Currently u

Vishal Menon 5 May 31, 2022
A wallet library for Elements / Liquid written in Rust!

EDK Elements Dev Kit A modern, lightweight, descriptor-based wallet library for Elements / Liquid written in Rust! Inspired by BDK for Elements & Liqu

luca vaccaro 11 Dec 11, 2021
Minimal Bitcoin wallet intended for teaching rust-bitcoin

Insanely minimal Bitcoin wallet intended for demonstration of Rust Bitcoin ecosystem Absolutely DO NOT use with mainnet funds!!! No privacy - address

Martin Habovštiak 4 May 5, 2023
Modern, lightweight & standard-compliant bitcoin wallet runtime & cli without rust-bitcoin dependencies

Bitcoin protocol command-line wallet & tools Modern, minimalistic & standard-compliant cold wallet from LNP/BP Standards Association. Contributing Con

BP: Bitcoin protocol 3 Jul 31, 2023
`llm-chain` is a powerful rust crate for building chains in large language models allowing you to summarise text and complete complex tasks

llm-chain ?? llm-chain is a collection of Rust crates designed to help you work with Large Language Models (LLMs) more effectively. Our primary focus

Sobel IO 36 Apr 6, 2023
An open source desktop wallet for nano and banano with end-to-end encrypted, on chain messaging using the dagchat protocol.

An open source wallet with end-to-end encrypted, on chain messaging for nano and banano using the dagchat protocol.

derfarctor 22 Nov 6, 2022
Automated Solana tool for quick arbitrage, customizable, with real-time data and wallet integration. Trade responsibly.

Solana Arbitrage Trading Tool The Solana Arbitrage Trading Tool is an automated solution crafted to spot and capitalize on arbitrage opportunities wit

null 43 Mar 12, 2024
🧩Creating a blockchain wallet and integrating a couple of cryptographic algorithms to securely save the secrets.🧩

Rust Library For Cryptocurrency Wallet Folder Structure src : contains the source code of the library examples : contains some examples of the library

rstkey 3 Aug 12, 2024
Vectis - Smart Contract Wallet

A smart contract wallet project to add functionality for users of DApps to manage their keys by allowing for recovery and account freeze, whilst preserving user control, and enabling relayer capability for gas provisioning

Nymlab 27 Dec 29, 2022
MyCitadel Wallet app for Linux, Windows & MacOS desktop made with GTK+

MyCitadel Desktop Bitcoin, Lightning and RGB wallet MyCitadel is a wallet for bitcoin, digital assets and bitcoin finance (#BiFi) smart contracts. It

My Citadel 88 Jan 2, 2023
MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose.

MevWallet MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose. This repo contains the so

Blunt Instruments 94 Jan 26, 2023
Radix Babylon vanity address finder allowing easy import into Radix mobile Wallet.

Rad Vanity address finder for Radix Babylon which you can import directly into your Radix Wallet using QR scanner using Import from a Legacy Wallet fe

Alexander Cyon 6 Nov 13, 2023
NymDrive is a complete, end-to-end encrypted file syncing daemon that runs over the Nym network.

NymDrive NymDrive is a complete, end-to-end encrypted file syncing daemon that runs over the Nym network. Features Active file monitoring of changes i

Hans Bricks 16 Jul 12, 2022
Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture.

?? Martinez ?? Next-generation implementation of Ethereum protocol ("client") written in Rust, based on Erigon architecture. Why run Martinez? Look at

Arthur·Thomas 23 Jul 3, 2022