Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
6bec948
readme command update
evanorti May 9, 2025
9969858
Update custom-components.mdx
evanorti May 9, 2025
92c9d64
docs-planning
evanorti May 9, 2025
e6bf2c6
Update variables.mdx
evanorti May 9, 2025
ca0760b
Update triggers.mdx
evanorti May 12, 2025
d35b20c
Update triggers.mdx
evanorti May 12, 2025
49e3b15
Update workflows.mdx
evanorti May 12, 2025
4857996
Merge branch 'main' into docs-0.4
evanorti May 12, 2025
4285525
Update workflows.mdx
evanorti May 13, 2025
f41ca0d
Update triggers.mdx
evanorti May 13, 2025
8b02b82
re-order component docs
evanorti May 14, 2025
408cf4c
Update component.mdx
evanorti May 14, 2025
14fa24f
Update component.mdx
evanorti May 14, 2025
a9d7f05
Merge branch 'main' into docs-0.4
evanorti May 15, 2025
65e62fb
Merge branch 'main' into docs-0.4
evanorti May 16, 2025
f7caede
Create cursor-rules.mdc
evanorti May 16, 2025
f128a3b
update handbook
evanorti May 16, 2025
3c06d41
cursor-script
evanorti May 16, 2025
a957640
rulefile script
evanorti May 16, 2025
10cde89
Update utilities.mdx
evanorti May 16, 2025
b87aa5d
Update component.mdx
evanorti May 16, 2025
79ea154
Update commands.mdx
evanorti May 16, 2025
df5170a
Update utilities.mdx
evanorti May 16, 2025
c9de9a8
Update service.mdx
evanorti May 16, 2025
f355869
Merge branch 'docs-0.4' into cursor-rules-generation
evanorti May 16, 2025
e767513
Update variables.mdx
evanorti May 19, 2025
43528ef
Update utilities.mdx
evanorti May 19, 2025
6468e50
Update component.mdx
evanorti May 19, 2025
8e8a2e8
update docs
evanorti May 19, 2025
2a4be43
update docs
evanorti May 19, 2025
469f4a7
Update triggers.mdx
evanorti May 20, 2025
b472417
Merge branch 'main' into docs-0.4
evanorti May 20, 2025
fe7f990
Update component.mdx
evanorti May 20, 2025
e93d954
Merge branch 'docs-0.4' into cursor-rules-generation
evanorti May 20, 2025
ff6cb1c
Merge branch '0.3' into cursor-rules-generation
evanorti May 20, 2025
271f3c8
Update service.mdx
evanorti May 20, 2025
63c2981
Update triggers.mdx
evanorti May 20, 2025
862c108
Update workflows.mdx
evanorti May 20, 2025
f63a6cd
Update submission.mdx
evanorti May 20, 2025
791e166
Update submission.mdx
evanorti May 20, 2025
909475d
Update component.mdx
evanorti May 20, 2025
415ad85
Update custom-components.mdx
evanorti May 20, 2025
8e26984
update docs
evanorti May 20, 2025
1f78ffb
Merge branch 'docs-0.4' into cursor-rules-generation
evanorti May 20, 2025
13c246e
Update doc_to_rule.py
evanorti May 21, 2025
d181eba
update docs
evanorti May 21, 2025
1a7f0e1
update docs
evanorti May 21, 2025
51ebf27
update
evanorti May 21, 2025
2726f52
Update component.mdx
evanorti May 21, 2025
d89b421
Update component.mdx
evanorti May 21, 2025
847fec1
Update design.mdx
evanorti May 21, 2025
905e415
Update submission.mdx
evanorti May 21, 2025
bb7ddf9
add docs page descriptions
evanorti May 21, 2025
2741913
Create llms.mdx
evanorti May 21, 2025
0ee8442
Merge branch 'docs-0.4' into cursor-rules-generation
evanorti May 21, 2025
e62ef08
update scripts
evanorti May 22, 2025
f6988f6
example rulefiles
evanorti May 25, 2025
3dace99
Merge branch 'main' into cursor-rules-generation
reecepbcups May 26, 2025
a6a6157
rm old utilities
reecepbcups May 26, 2025
f19f77c
refactor(cursor-rules-generation): latest cursor rules generation (#171)
reecepbcups May 26, 2025
4b390d5
remove old
reecepbcups May 26, 2025
99046e6
rm legacy python stuff
reecepbcups May 26, 2025
3d14158
Merge branch 'main' into cursor-rules-generation
evanorti May 28, 2025
1afe77e
Update Makefile
evanorti May 29, 2025
3e8e6f1
Update trigger.rs
evanorti May 29, 2025
54da871
Delete utilities.mdc
evanorti May 29, 2025
6f40854
Update Makefile
evanorti May 29, 2025
bbbe911
update rules
evanorti May 29, 2025
79a883c
import files
evanorti Jun 2, 2025
2956194
Update claude.md
evanorti Jun 3, 2025
11d9736
Update claude.md
evanorti Jun 3, 2025
ffa8167
update
evanorti Jun 3, 2025
032961a
Update lib.rs
evanorti Jun 3, 2025
35fd87f
Update claude.md
evanorti Jun 3, 2025
93a9fb7
Update Cargo.toml
evanorti Jun 4, 2025
83741d2
Update blockchain-interactions.mdc
evanorti Jun 4, 2025
f9cd065
Create component-rules.mdc
evanorti Jun 4, 2025
ff87a2d
Update claude.md
evanorti Jun 4, 2025
8bbef33
Update claude.md
evanorti Jun 4, 2025
e90f954
Update validate_component.sh
evanorti Jun 4, 2025
559a847
Update claude.md
evanorti Jun 4, 2025
fb3c5fe
Update claude.md
evanorti Jun 4, 2025
f6e5d8c
Update Makefile
evanorti Jun 4, 2025
684a557
Update component-rules.mdc
evanorti Jun 4, 2025
c39bec8
Delete making-components.mdc
evanorti Jun 4, 2025
04f9359
Update claude.md
evanorti Jun 4, 2025
7001048
Merge branch 'main' into claude.md
evanorti Jun 4, 2025
6e08ccc
Delete llms.mdx
evanorti Jun 5, 2025
470dbdd
Update component-rules.mdc
evanorti Jun 5, 2025
758cd9a
feat!(rust): generalized abi decoder in rust component (#201)
reecepbcups Jun 5, 2025
6d3ed55
hardcoded, working exec
reecepbcups Jun 5, 2025
90821d4
go: working without hardcode
reecepbcups Jun 5, 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
153 changes: 153 additions & 0 deletions .cursor/rules/blockchain-interactions.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
---
description:
globs:
alwaysApply: true
---
# Blockchain Interactions in WAVS Components

Use the `wavs-wasi-utils` crate and Alloy ecosystem crates to interact with Ethereum and EVM-compatible chains from WAVS components. Configure chains in `wavs.toml` and generate Rust types from Solidity using the `sol!` macro.

1. **Setup dependencies in Cargo.toml:**

```toml
[dependencies]
wit-bindgen-rt = { version = "0.42.1", features = ["bitflags"] }
wit-bindgen = "0.42.1"
wavs-wasi-utils = "0.4.0-beta.4"
wstd = "0.5.3"

alloy-sol-macro = { version = "1.1.0", features = ["json"] }
alloy-sol-types = "1.1.0"
alloy-network = "0.15.10"
alloy-provider = { version = "0.15.10", default-features = false, features = ["rpc-api"] }
alloy-rpc-types = "0.15.10"
alloy-contract = "0.15.10"

anyhow = "1.0.98"
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
```

Use `workspace = true` if managing versions centrally.

2. **Configure chains in `wavs.toml`:**

```toml
[default.chains.evm.local]
chain_id = "31337"
ws_endpoint = "ws://localhost:8545"
http_endpoint = "http://localhost:8545"
poll_interval_ms = 7000

[default.chains.evm.ethereum]
chain_id = "1"
ws_endpoint = "wss://eth.drpc.org"
http_endpoint = "https://eth.drpc.org"
```

3. **Generate Rust types from Solidity with `sol!` macro:**

```rust
mod solidity {
use alloy_sol_macro::sol;

// From Solidity file
sol!("../../src/interfaces/ITypes.sol");

// Or inline Solidity definitions
sol! {
struct TriggerInfo {
uint64 triggerId;
bytes data;
}

event NewTrigger(TriggerInfo _triggerInfo);
}
}
```

4. **Access chain config and create provider:**

```rust
use crate::bindings::host::get_evm_chain_config;
use alloy_network::Ethereum;
use alloy_provider::RootProvider;
use wavs_wasi_utils::evm::new_evm_provider;

let chain_config = get_evm_chain_config("local").unwrap();
let provider: RootProvider<Ethereum> = new_evm_provider::<Ethereum>(
chain_config.http_endpoint.unwrap(),
);
```

5. **Example: Query ERC721 NFT balance**

```rust
use crate::bindings::host::get_evm_chain_config;
use alloy_network::Ethereum;
use alloy_provider::RootProvider;
use alloy_sol_types::sol;
use wavs_wasi_utils::evm::{alloy_primitives::{Address, U256}, new_evm_provider};
use alloy_rpc_types::TransactionInput;
use wstd::runtime::block_on;

sol! {
interface IERC721 {
function balanceOf(address owner) external view returns (uint256);
}
}

pub fn query_nft_ownership(address: Address, nft_contract: Address) -> Result<bool, String> {
block_on(async move {
let chain_config = get_evm_chain_config("local").unwrap();
let provider: RootProvider<Ethereum> = new_evm_provider::<Ethereum>(
chain_config.http_endpoint.unwrap()
);

let balance_call = IERC721::balanceOf { owner: address };

let tx = alloy_rpc_types::eth::TransactionRequest {
to: Some(TxKind::Call(nft_contract)),
input: TransactionInput { input: Some(balance_call.abi_encode().into()), data: None },
..Default::default()
};

let result = provider.call(tx).await.map_err(|e| e.to_string())?;
let balance: U256 = U256::from_be_slice(&result);
Ok(balance > U256::ZERO)
})
}
```

6. **Best practices and guidelines:**

- Use `wavs.toml` for chain configuration to avoid hardcoding endpoints.
- Use `sol!` macro to generate Rust bindings from Solidity interfaces for type safety.
- Use `new_evm_provider` to create providers from chain config endpoints.
- Use `block_on` from `wstd` to run async code synchronously in components.
- Handle errors with `anyhow` or proper error propagation.
- Rebuild after updating Solidity files to regenerate Rust types.

7. **Useful crates:**

- `wavs-wasi-utils`: HTTP and blockchain interaction utilities, including `decode_event_log_data` macro.
- Alloy crates (`alloy-primitives`, `alloy-provider`, `alloy-network`, `alloy-sol-types`, `alloy-sol-macro`): Ethereum types, network, ABI handling, and Solidity macro.
- `wstd`: WASI standard library with async utilities.
- `serde`/`serde_json`: Serialization and JSON handling.
- `anyhow`: Error handling.

For more information:
- [wavs-wasi-utils crate documentation](mdc:https:/docs.rs/wavs-wasi-utils/latest/wavs_wasi_utils/index.html)
- [Alloy sol! macro documentation](mdc:https:/docs.rs/alloy-sol-macro/latest/alloy_sol_macro/macro.sol.html)
- [Utilities and crates page](mdc:utilities)
- [wavs-wasi-utils docs](mdc:https:/docs.rs/wavs-wasi-utils/latest/wavs_wasi_utils)
- [Alloy documentation](mdc:https:/docs.rs/alloy/latest/alloy)
- [Example querying NFT ownership](mdc:https:/github.com/Lay3rLabs/wavs-art/blob/main/components/autonomous-artist/src/evm.rs)
- [alloy-primitives](mdc:https:/docs.rs/alloy-primitives/latest/alloy_primitives)
- [alloy-provider](mdc:https:/docs.rs/alloy-provider/latest/alloy_provider)
- [alloy-network](mdc:https:/docs.rs/alloy-network/latest/alloy_network)
- [alloy-sol-types](mdc:https:/docs.rs/alloy-sol-types/latest/alloy_sol_types)
- [wstd](mdc:https:/docs.rs/wstd/latest/wstd)
- [serde](mdc:https:/docs.rs/serde/latest/serde)
- [serde_json](mdc:https:/docs.rs/serde_json/latest/serde_json)
- [](mdc:https:/docs.rs/anyhow/latest/anyhow)
54 changes: 54 additions & 0 deletions .cursor/rules/commands.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
description:
globs:
alwaysApply: true
---
# Makefile Commands for WAVS Development

This rule summarizes the CLI commands available in the WAVS Makefile for building, testing, deploying, and managing WAVS components and services.

1. Common commands:
- `make help`: Show help information.
- `build`: Build the project.
- `wasi-build`: Build WAVS WASI components. Uses `WASI_BUILD_DIR`.
- `wasi-exec`: Execute WAVS WASI components. Requires `COMPONENT_FILENAME`, `COIN_MARKET_CAP_ID`.
- `clean`: Clean project files.
- `clean-docker`: Remove unused Docker containers.
- `fmt`: Format Solidity and Rust code.
- `test`: Run tests.
- `setup`: Install initial dependencies.
- `start-all-local`: Start local services like Anvil and IPFS.
- `update-submodules`: Update git submodules.
- `check-requirements`: Verify system requirements.

2. Deployment and service management:
- `upload-component`: Upload WAVS component. Requires `COMPONENT_FILENAME`, `WAVS_ENDPOINT`.
- `deploy-service`: Deploy WAVS component service JSON. Requires `SERVICE_URL`, `CREDENTIAL`, `WAVS_ENDPOINT`.
- `get-trigger-from-deploy`: Get trigger address from deploy script.
- `get-submit-from-deploy`: Get submit address from deploy script.
- `get-trigger`: Get trigger ID. Requires `SERVICE_TRIGGER_ADDR`, `RPC_URL`.
- `show-result`: Show result. Requires `SERVICE_SUBMISSION_ADDR`, `TRIGGER_ID`, `RPC_URL`.
- `upload-to-ipfs`: Upload service config to IPFS. Requires `SERVICE_FILE`, optional `[PINATA_API_KEY]`.

3. Operator management:
- `operator-list`: List AVS operators. Requires `ENV_FILE`.
- `operator-register`: Register AVS operators. Requires `ENV_FILE`, `AVS_PRIVATE_KEY`.

Guidelines:
- Use environment variables as indicated for commands requiring parameters.
- Run `make help` to see available commands.
- Use `clean` and `clean-docker` to maintain a clean environment.
- Format code regularly with `fmt` to maintain consistency.
- Use `setup` before starting development to install dependencies.

Example usage:
```bash
make build
make wasi-build
make upload-component COMPONENT_FILENAME=component.wasm WAVS_ENDPOINT=https://wavs.example.com
make operator-register ENV_FILE=.env AVS_PRIVATE_KEY=key123
```

For more information:
- [WAVS Documentation](mdc:https:/docs.wavs.example.com)
- [](mdc:https:/www.gnu.org/software/make/manual/make.html)
Loading