Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b6ef2c1
Implement NEAR CLI using aurora-sdk-rs
Qjawko Jun 26, 2025
52d1375
feat: add output formatting
Qjawko Jul 1, 2025
ffdd366
feat: add missing commands
Qjawko Jul 4, 2025
07dfafc
feat: add missing methods, fix ci
Qjawko Jul 6, 2025
2affc36
fix: review fixes, remove 'expect' calls, fix typos
Qjawko Jul 7, 2025
2127357
simplify and split command and handle logic
Qjawko Jul 7, 2025
05eb850
fix: code rabbit issues
Qjawko Jul 7, 2025
2a52c46
fix: simplify output formatting for latest hashchain
Qjawko Jul 7, 2025
f5c80f0
fix get nonce method and readme
Qjawko Jul 8, 2025
debc44d
chore: add clone for aurora client
aleksuss Jul 12, 2025
0e431ae
chore: non-contract-usage for near-sdk
aleksuss Jul 12, 2025
ef83098
Merge branch 'main' into new-cli
aleksuss Jul 13, 2025
2981c12
feat: view method with block number
aleksuss Jul 13, 2025
6465bd0
Merge branch 'main' into new-cli
aleksuss Jul 14, 2025
1fc3c7d
chore: update dependencies and features in Cargo.toml files
Qjawko Jul 21, 2025
edbc259
fix: update tokio features and aurora-engine-types dependency configu…
Qjawko Jul 21, 2025
35b550a
fix: update CLI paths in workflow configuration
Qjawko Jul 22, 2025
806efc8
fix: add missing binary configuration for aurora-cli in Cargo.toml
Qjawko Jul 22, 2025
33523fa
fix: enhance CLI configuration and error handling for NEAR signer
Qjawko Jul 22, 2025
c60a322
fix: clean up unused imports and enhance NearGas default configuration
Qjawko Jul 22, 2025
c639010
fix: change default network from Mainnet to Localnet in CLI configura…
Qjawko Jul 22, 2025
7c4f629
fix: add debug output for command execution in CLI
Qjawko Jul 22, 2025
0f934cc
fix: add debug output for command execution in run function
Qjawko Jul 22, 2025
e08cd2a
fix: improve error handling for signer file reading and update output…
Qjawko Jul 22, 2025
ad7317d
fix: update create_account function to return SecretKey and adjust ou…
Qjawko Jul 23, 2025
a2854d0
feat: split cli and handlers
Qjawko Jul 23, 2025
94e21d2
chore: get neard version from rpc
aleksuss Jul 23, 2025
a35e7a9
chore: cargo fmt
aleksuss Jul 23, 2025
5823922
chore: use macros for code clarity and less bloatness
Qjawko Jul 23, 2025
ed67d00
refactor: simplify handle_near_call macro by removing outdated syntax
Qjawko Jul 23, 2025
60b45f2
fix: enhance error handling in deploy_aurora function and update outp…
Qjawko Jul 24, 2025
0b21a2a
refactor: introduce read_wasm_file function and ability to parse sig…
Qjawko Jul 24, 2025
3b6f495
chore: remove println!
aleksuss Jul 28, 2025
8aec8db
fix: trim "0x" prefix from address input in parse_address function
Qjawko Jul 29, 2025
d15196a
fix: change bridge_prover_id to optional in init and update handling …
Qjawko Jul 29, 2025
7b6ac06
fix: specify gas for contract calls
Qjawko Jul 29, 2025
45a885d
fix: adjust create_account function to convert balance to near
Qjawko Jul 29, 2025
8c3a366
fix: change default output format to plain and update CLI command usage
Qjawko Jul 29, 2025
9d29667
fix: update init function to return FinalExecutionOutcomeView and han…
Qjawko Jul 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
[workspace]
resolver = "3"
members = [
"cli",
"cli", "newcli",
"sdk"
]

Expand All @@ -20,6 +20,7 @@ aurora-engine-precompiles = { version = "1", features = ["std"] }
aurora-engine-sdk = { version = "1", features = ["std"] }
aurora-engine-transactions = { version = "1", features = ["std"] }
aurora-engine-types = { version = "1", features = ["std", "impl-serde"] }
base64 = "0.22"
borsh = "1"
bs58 = "0.5"
clap = "4"
Expand Down
85 changes: 50 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,28 @@

## What is Engine?

[Aurora](https://doc.aurora.dev/getting-started/aurora-engine/) is an Ethereum Virtual Machine (EVM)
project built on the NEAR Protocol, that provides a solution for developers to deploy their apps
on an Ethereum-compatible, high-throughput, scalable and future-safe platform, with low transaction costs
[Aurora](https://doc.aurora.dev/getting-started/aurora-engine/) is an Ethereum
Virtual Machine (EVM) project built on the NEAR Protocol, that provides a
solution for developers to deploy their apps on an Ethereum-compatible,
high-throughput, scalable and future-safe platform, with low transaction costs
for their users. Engine is the Aurora's implementation for it.

## What is Aurora CLI?

Aurora CLI is a command line interface to bootstrap Aurora Engine with rapid speed built with rust.
Aurora CLI is a command line interface to bootstrap Aurora Engine with rapid
speed built with rust.

Aurora CLI comes pre-configuration with opinionated, sensible defaults for standard testing environments.
If other projects mention testing on Aurora, they are referring to the settings defined in this repo.
Aurora CLI comes pre-configuration with opinionated, sensible defaults for
standard testing environments. If other projects mention testing on Aurora, they
are referring to the settings defined in this repo.

**Aurora CLI has the following advantages over api:**

- :pencil: **Easily modifiable EVM states through terminal**
- :handshake: **Quick to interact for rapid iterations**

See also prior version [aurora-cli](https://github.com/aurora-is-near/aurora-cli).
See also prior version
[aurora-cli](https://github.com/aurora-is-near/aurora-cli).

## Prerequisites

Expand All @@ -40,14 +44,17 @@ See also prior version [aurora-cli](https://github.com/aurora-is-near/aurora-cli
## Quickstart

- 📦 Install `aurora-cli-rs` and start interacting with it:
*`cargo install --git https://github.com/aurora-is-near/aurora-cli-rs.git`*
- 🔍 Check out what each command is for in the [Commands Reference](#commands-reference) section
- ✋ Have questions? Ask them at the official Aurora [forum](https://forum.aurora.dev/)
_`cargo install --git https://github.com/aurora-is-near/aurora-cli-rs.git`_
- 🔍 Check out what each command is for in the
[Commands Reference](#commands-reference) section
- ✋ Have questions? Ask them at the official Aurora
[forum](https://forum.aurora.dev/)

## Usage

In the following example, we will see how to deploy Aurora EVM on the `localnet`. Also, we will deploy a simple EVM
smart contract and will be interacting with it.
In the following example, we will see how to deploy Aurora EVM on the
`localnet`. Also, we will deploy a simple EVM smart contract and will be
interacting with it.

### **Requirements**

Expand All @@ -60,10 +67,11 @@ First what we need to do is to install `aurora-cli`:

```shell
git clone https://github.com/aurora-engine/aurora-cli-rs
cd aurora-cli-rs/cli && cargo install --path .
cd aurora-cli-rs/cli && cargo install --path .
```

Next we need to start a NEAR node locally. We can use the NEAR utility, `nearup`.
Next we need to start a NEAR node locally. We can use the NEAR utility,
`nearup`.

### **Start a NEAR node locally**

Expand All @@ -79,16 +87,18 @@ Start NEAR node:
nearup run localnet --home /tmp/localnet
```

When running the `nearup run localnet` command on Apple’s M-based hardware, a local build of `neard` is required due to
compatibility issues with the architecture.
When running the `nearup run localnet` command on Apple’s M-based hardware, a
local build of `neard` is required due to compatibility issues with the
architecture.

Start NEAR node (Apple's M-based hardware):

```shell
nearup run localnet --home /tmp/localnet --binary-path /path/to/nearcore/target/release
```

Replace `/path/to/nearcore/target/release` with the actual path to the locally built `neard` binary.
Replace `/path/to/nearcore/target/release` with the actual path to the locally
built `neard` binary.

### **Prepare an account and create a private key file for Aurora EVM**

Expand Down Expand Up @@ -125,8 +135,9 @@ aurora-cli --engine aurora.node0 --near-key-path /tmp/localnet/aurora_key.json i

### **Deploy the EVM smart contract**

And now we can deploy the EVM smart contract. In our example, it will be a simple counter that can return its current
value and increment and decrement its value.
And now we can deploy the EVM smart contract. In our example, it will be a
simple counter that can return its current value and increment and decrement its
value.

But before that we need to generate a private key for signing transactions:

Expand Down Expand Up @@ -161,13 +172,14 @@ If everything went well, the response should be like this:
Contract has been deployed to address: 0x53a9fed853e02a39bf8d298f751374de8b5a6ddf successfully
```

So. Now we have deployed the smart contract at address: `0x53a9fed853e02a39bf8d298f751374de8b5a6ddf`.
So. Now we have deployed the smart contract at address:
`0x53a9fed853e02a39bf8d298f751374de8b5a6ddf`.

### **Interact with the smart contract**

First, let's check that the current value is the same as we set in the
initialization stage. For that, we will use the `view-call` operation, which doesn't demand a private key
because it is a read-only operation:
initialization stage. For that, we will use the `view-call` operation, which
doesn't demand a private key because it is a read-only operation:

```shell
aurora-cli --engine aurora.node0 view-call -a 0x53a9fed853e02a39bf8d298f751374de8b5a6ddf -f value \
Expand All @@ -186,8 +198,8 @@ aurora-cli --engine aurora.node0 --near-key-path /tmp/localnet/aurora_key.json s
--aurora-secret-key 3fac6dca1c6fc056b971a4e9090afbbfbdf3bc443e9cda595facb653cb1c01e1
```

In the response, we can see if the transaction was successful and the amount of gas used for the execution of this
transaction.
In the response, we can see if the transaction was successful and the amount of
gas used for the execution of this transaction.

Let's make sure that our value was incremented:

Expand All @@ -200,13 +212,15 @@ So, if we can see `6` in the output then the demo was successful. That's it!

### **Build aurora-cli with the advanced command line interface (Advanced CLI)**

Advanced CLI provides more options andadvanced features. You can try it by building with the following command:
Advanced CLI provides more options andadvanced features. You can try it by
building with the following command:

```shell
cargo install --path . --no-default-features -F advanced
```

Documentation on how to work with the advanced version of `aurora-cli` can be found [here](docs/localnet.md).
Documentation on how to work with the advanced version of `aurora-cli` can be
found [here](docs/localnet.md).

### **Browse Deployed EVM Metadata**

Expand Down Expand Up @@ -269,17 +283,19 @@ Disable whitelist status
aurora-cli --engine aurora.node0 set-whitelist-status --kind <whitelist-kind> --status 0
```

Replace `<whitelist-kind>` with the desired whitelist type (admin, evm-admin, account, or address), and `<entry-value>`
with the address or account to be whitelisted or removed.
Replace `<whitelist-kind>` with the desired whitelist type (admin, evm-admin,
account, or address), and `<entry-value>` with the address or account to be
whitelisted or removed.

Add whitelist batch

```shell
aurora-cli --engine aurora.node0 add-entry-to-whitelist-batch path/to/batch_list.json
```

The batch should be provided in a JSON format. Each entry in the JSON array should have two properties: `kind` and
either `account_id` or `address`, depending on the type of whitelist being updated.
The batch should be provided in a JSON format. Each entry in the JSON array
should have two properties: `kind` and either `account_id` or `address`,
depending on the type of whitelist being updated.

Example JSON batch file (`batch_list.json`):

Expand Down Expand Up @@ -439,6 +455,7 @@ Options:
--network <NETWORK> NEAR network ID [default: localnet]
--engine <ACCOUNT_ID> Aurora EVM account [default: aurora]
--near-key-path <NEAR_KEY_PATH> Path to file with NEAR account id and secret key in JSON format
--block-number Block number to get data from
-h, --help Print help
-V, --version Print version
```
Expand Down Expand Up @@ -537,7 +554,6 @@ Arguments:

Options:
-h, --help Print help

```

### `aurora-cli get-block-hash`
Expand Down Expand Up @@ -568,7 +584,6 @@ Arguments:

Options:
-h, --help Print help

```

### `aurora-cli get-balance`
Expand Down Expand Up @@ -867,7 +882,7 @@ Options:
--value <VALUE> Attached value in EVM transaction
--from <FROM> From account_id
-h, --help Print help
```
```

### `aurora-cli submit`

Expand Down Expand Up @@ -1202,7 +1217,7 @@ Usage: aurora-cli set-eth-connector-contract-account [OPTIONS] --account-id <ACC
Options:
--account-id <ACCOUNT_ID> Account id of eth connector
--withdraw-ser <WITHDRAW_SER> Serialization type in withdraw method
-h, --help
-h, --help
```

### `aurora-cli get-eth-connector-contract-account`
Expand Down Expand Up @@ -1290,4 +1305,4 @@ Options:
--full-access-pub-key <FULL_ACCESS_PUB_KEY>
--function-call-pub-key <FUNCTION_CALL_PUB_KEY>
-h, --help Print help
```
```
21 changes: 21 additions & 0 deletions newcli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "newcli"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
homepage.workspace = true
repository.workspace = true
readme.workspace = true

[dependencies]
anyhow.workspace = true
aurora-sdk-rs = {path = "../sdk" }
base64.workspace = true
clap = { workspace = true, features = ["derive"] }
libsecp256k1 = { workspace = true, features = ["std"] }
rlp.workspace = true
hex.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
81 changes: 81 additions & 0 deletions newcli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use std::{path::PathBuf, str::FromStr};

use aurora_sdk_rs::near::{
crypto::{InMemorySigner, Signer},
primitives::types::AccountId,
};
use clap::{Parser, ValueEnum, command};

use crate::command::Command;

#[derive(Debug, Clone, ValueEnum)]
pub enum Network {
Localnet,
Mainnet,
Testnet,
}
impl Network {
pub fn rpc_url(&self) -> &str {
match self {
Network::Localnet => "http://localhost:3030",
Network::Mainnet => "https://rpc.mainnet.near.org",
Network::Testnet => "https://rpc.testnet.near.org",
}
}
}

#[derive(Parser)]
#[command(author, long_about = None)]
pub struct Cli {
/// Near network ID
#[arg(long, value_enum, default_value_t = Network::Localnet)]
pub network: Network,
/// Aurora EVM account
#[arg(long, value_name = "ACCOUNT_ID", default_value = "aurora")]
pub engine: AccountId,
/// The way output of a command would be formatted
#[arg(long, default_value = "plain")]
pub output_format: OutputFormat,
/// Path to file with NEAR account id and secret key in JSON format
#[arg(long)]
pub near_key_path: PathBuf,
#[clap(subcommand)]
pub command: Command,
}

impl Cli {
pub(crate) fn signer(&self) -> anyhow::Result<Signer> {
InMemorySigner::from_file(&self.near_key_path).map_err(Into::into)
}

pub(crate) fn root_contract_id(&self) -> anyhow::Result<AccountId> {
let account = match self.network {
Network::Testnet => "testnet",
Network::Mainnet => "near",
Network::Localnet => {
anyhow::bail!("Account creation is only supported for mainnet or testnet")
}
};

account.parse().map_err(Into::into)
}
}

#[derive(Default, Clone, ValueEnum)]
pub enum OutputFormat {
#[default]
Plain,
Json,
}

impl FromStr for OutputFormat {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"plain" => Ok(Self::Plain),
"json" => Ok(Self::Json),
_ => anyhow::bail!("unknown output format: {s}"),
}
}
}
Loading
Loading