1

I have deployed the Counter contract to the Stylus testnet. However, looking at verification options, it looks like only Solidity & Vyper is supported.

Is there a way to verify a Stylus (rust-based) contract?

The code is here:

//! Implements a hello-world example for Arbitrum Stylus, providing a Solidity ABI-equivalent
//! Rust implementation of the Counter contract example provided by Foundry.
//! Warning: this code is a template only and has not been audited.
//! ```
//! contract Counter {
//!     uint256 public number;
//!     function setNumber(uint256 newNumber) public {
//!         number = newNumber;
//!     }
//!     function increment() public {
//!         number++;
//!     }
//! }
//! ```

// Only run this as a WASM if the export-abi feature is not set.
#![cfg_attr(not(feature = "export-abi"), no_main)]
extern crate alloc;

/// Initializes a custom, global allocator for Rust programs compiled to WASM.
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

/// Import the Stylus SDK along with alloy primitive types for use in our program.
use stylus_sdk::{alloy_primitives::U256, prelude::*};

// Define the entrypoint as a Solidity storage object, in this case a struct
// called `Counter` with a single uint256 value called `number`. The sol_storage! macro
// will generate Rust-equivalent structs with all fields mapped to Solidity-equivalent
// storage slots and types.
sol_storage! {
    #[entrypoint]
    pub struct Counter {
        uint256 number;
    }
}

/// Define an implementation of the generated Counter struct, defining a set_number
/// and increment method using the features of the Stylus SDK.
#[external]
impl Counter {
    /// Gets the number from storage.
    pub fn number(&self) -> Result<U256, Vec<u8>> {
        Ok(self.number.get())
    }

    /// Sets a number in storage to a user-specified value.
    pub fn set_number(&mut self, new_number: U256) -> Result<(), Vec<u8>> {
        self.number.set(new_number);
        Ok(())
    }

    /// Increments number and updates it values in storage.
    pub fn increment(&mut self) -> Result<(), Vec<u8>> {
        let number = self.number.get();
        self.number.set(number + U256::from(1));
        Ok(())
    }
}

1 Answer 1

1

Well, what is verification? It's something not related to the blockchain per se, but about blockchain explorers. And the only explorer I could find was https://stylus-testnet-explorer.arbitrum.io/ , which utilizes Blockscout explorer.

I'm not very familiar with Blockscout, but it's for "EVM based blockchains". Stylus is only loosely EVM-based - they call it "EVM+". Therefore, Blockscout doesn't support Stylus contracts (or maybe, if you get lucky, it might support the Solidity Stylus contracts, don't really know).

So I would say this is a question more for the Blockscout development team: will they support EVM+ blockchain contract verifications.

Or maybe someone sets up another explorer where verification is supported. But I would say that is not likely to happen in near future, since it would require very customized EVM+ compatibility code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.