VS Code Ethers Mode
Ethers Mode allows you to explore and call Smart Contracts methods using Ethers.js and view the response directly in VS Code.
It interacts with any EVM-compatible blockchain, e.g., Ethereum, Polygon, Avalanche, etc.
It uses VS CodeLens to display contextual information about Contracts, Externally Owned Accounts and networks.
Main Features
- Call Smart Contract method by writing its Human-Readable ABI Signature
- Detect contract or EOA address and provide its balance
- Call multiple Smart Contract methods in a single file
- Send method arguments and autodetect argument types
- View return value as a notification (CHANGE)
- Provide network info
- Select multiple network in a single file networks (using
net <network name | RPC URL>
)
- Error reporting as you type
- Alias definitions with
as
and this
- Send and sign transactions using private keys
- Ether CashFlow report for block ranges and block contextual information
Ethers
language support
.ethers
and .web3
file extensions
- Syntax highlight of Human-Readable ABI Signatures if Solidity extension is installed
- TODO Auto completion for method, url, header, custom/system variables, mime types and so on
- Comments (line starts with
#
) support
- Code snippets for several ERCs
- TODO Support navigate to symbol definitions(request and file level custom variable) in open
http
file
- CodeLens support to add an actionable link to call method
- CHECK Fold/Unfold for request block
And more
- Auto detect language mode using
net
declaration
Usage
In a new editor, select a network, followed by a contract address and a method call
net fuji
0x5425890298aed601595a70AB815c96711a31Bc65
name() view returns (string)
Once you prepared a Smart Contract method call,
click the Call Smart Contract Method
link above the call
(this will appear if the file's language is Ethers
, by default .ethers
and .web3
files are like this).
Features
Aliases
You can define aliases using the as
keyword.
These aliases can be used to reference the aliased address within another address.
Moreover, you can use the this
reference to use the address in the current scope.
Hovers & Decompile
Provide connection info and decompilation of smart contracts.
Sending and Signing Transactions
To send and sign transactions,
you can provide a private key for an account.
The address will be displayed as a code lens.
Display inferred types
When you omit the type of an argument, it will display an inlay with the inferred type.
Blocks and Ether CashFlow
Allows you display single block or block range information by proving a contextual hover.
Moreover, you can calculate the Ether CashFlow of the entire block range.
Use -
as a block number separator to denote a block range.
Snippets
When you know that a contract implements a specific ERC,
you can use snippets to insert its methods.
The errors are caused because on methods that require sending a transaction without specifying a signer.
Error Reporting
Whenever there is a syntax error or the method call is inconsistent, e.g., trying to send a transaction without a signer, the extension will show provide diagnostics about them.
Language Auto Detection
Just write net <provider>
at the beginning of the file and select
Change Language Mode -> Auto Detect
.
a
sdsd
net sdsd
net
Contributing
- Execute
yarn install
in terminal to install dependencies
- Execute the
Run Extension
target in the Debug View.
This will:
- Start a task
npm: watch
to compile the code
- Run the extension in a new VS Code window
Typechecking and Building
To typecheck the extension using tsc
, run
yarn compile
To build and package the extension we use the esbuild
bundler.
To bundle the extension into dist/main.js
, run
yarn build
Unit Testing
Unit tests can be found under the test
folder.
Our test suite uses mocha
to run the tests.
yarn test
VS Code Testing
TODO!
VS Code API Overview
languages
module
The extension uses languages.registerCodeLensProvider
to register the CodeLensProvider
.