Smart contract explorer on stats.gallery

Hi there! Jacob here with a new feature announcement on stats.gallery.

Introducing… the smart contract explorer!

Simply navigate to a smart contract account and click on the “Contract” tab to see the interactions interface. Example

Each of the buttons represents a method you can call on the contract. In this example, the contract also implements a few standard NEP interfaces. Those are auto-detected and have extra integrated functionality.

Let’s take a look at the ft_metadata method.

An NEP-148 standard-compliant ft_metadata method implementation is a view method that doesn’t take any arguments, so we can just click on the “View” button.

Let’s try ft_balance_of, which takes an account ID as an argument.

What about non-standard method calls? stats.gallery has a clever auto-detect feature to help you choose parameters. It’s not always perfect, so you can modify them however you like.

What if you want to actually call a method on-chain instead of just viewing its state? Well, first we’ll have to log into the contract on stats.gallery.

firefox_2021-12-20-19-49-04

Once you log in, you’ll be able to perform method calls on-chain, just like in any other dapp.

Enjoy!


WARNING: This tool provides an extremely generic UI over WASM smart contracts. It is not guaranteed to perform the same operations as, for example, method calls mediated by the NEAR CLI or a smart contract’s dedicated dapp. You should always double-check the method call and arguments on the transaction confirmation screen. Use at your own risk!

11 Likes

Nice work - this is excellent. One question - when viewing a contract (did.near) - I’m getting duplicate function names in the form of:

  • transferAdmin and transfer_admin
  • getDID and get_did
  • etc…

Curious as to why that is? It’s the first form that is defined in the contract.

2 Likes

I think that AssemblyScript contracts generate method names of both forms for easier cross-contract interactions, since AssemblyScript/JavaScript naming conventions are camelCase and Rust uses snake_case.

3 Likes

I did not know that. Thanks both for the smart contract explorer and for teaching me something new today. Appreciate it.

4 Likes

Update: I have extracted the contract parsing code into an easy-to-use NPM package: near-contract-parser. Now you can integrate this functionality into your own applications as well!

5 Likes

solid work @Jacob, looking forward to what you create in 2022

4 Likes