Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Context and Proxy Starknet contract integration into Calimero #981

Merged
merged 26 commits into from
Nov 26, 2024

Conversation

alenmestrov
Copy link
Member

@alenmestrov alenmestrov commented Nov 21, 2024

Integrate Starknet Blockchain integration into Calimero

Summary

Implemented logic for communicating with Starknet smart contracts (both Context and Proxy contracts).
The implementation was done based on NEAR integration. For some cases we needed to include custom logic for casting from NEAR to Starknet and vice versa.

Test plan

Setup of devnet environment and preparation of contracts can be found in these two repositories:
Context contract
Proxy contract

  1. Initialize the node with additional flag --protocol starknet
cargo run -p merod -- --node-name starknet --home data init --server-port 2428 --swarm-port 2528 --protocol starknet
  1. After initialization go to Config.toml file in node directory and adjust the values there to use devnet environment.
[context.config.new]
protocol = "starknet"
network = "sepolia"
contract_id = "HERE_INSERT_CONTEXT_CONTRACT_ADDRESS"
  1. Set context.config.signer use value to self
[context.config.signer]
use = "self"
  1. Adjust signer details:
[context.config.signer.self.starknet.sepolia]
rpc_url = "http://127.0.0.1:5050/rpc"
account_id = "USE_ONE_OF_DEVNET_ACCOUNT_ADDRESSES"
public_key = "ACCOUNT_PUBLIC_KEY"
secret_key = "ACCOUNT_SECRET_KEY"
  1. Start the node
cargo run -p merod -- --node-name starknet --home data run
  1. Setup Demo Blockchain application
    Repository

  2. In first node install application wasm, create context, then initalize one more node on different ports, and add that node to context created in first node.
    Steps are explained here

  3. Start Demo blockchain app frontend, connect to nodes through Admin Dashboard

  4. Create demo proposal and approve proposal on different node

  5. Results should be visible on both nodes

@alenmestrov alenmestrov self-assigned this Nov 21, 2024
Cargo.toml Outdated Show resolved Hide resolved
crates/node/src/sync.rs Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
crates/context/Cargo.toml Outdated Show resolved Hide resolved
crates/context/config/src/client/env/config/mutate.rs Outdated Show resolved Hide resolved
crates/context/config/src/client/env/config/mutate.rs Outdated Show resolved Hide resolved
crates/context/config/src/client/protocol/starknet.rs Outdated Show resolved Hide resolved
crates/context/config/src/client/protocol/starknet.rs Outdated Show resolved Hide resolved
crates/context/config/src/lib.rs Outdated Show resolved Hide resolved
crates/context/config/src/types.rs Outdated Show resolved Hide resolved
crates/context/src/lib.rs Outdated Show resolved Hide resolved
@alenmestrov alenmestrov marked this pull request as ready for review November 25, 2024 16:17
crates/context/config/src/client/env/config/mutate.rs Outdated Show resolved Hide resolved
crates/context/config/src/client/env/config/mutate.rs Outdated Show resolved Hide resolved
crates/context/config/src/lib.rs Outdated Show resolved Hide resolved
crates/context/src/lib.rs Outdated Show resolved Hide resolved
crates/primitives/src/context.rs Outdated Show resolved Hide resolved
Comment on lines 36 to 39
let felt_pair: FeltPair = self.context_id.into();
let mut call_data = CallData::default();
felt_pair.encode(&mut call_data)?;
Ok(call_data.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@alenmestrov alenmestrov merged commit 805cc18 into master Nov 26, 2024
16 checks passed
@alenmestrov alenmestrov deleted the feat/context_contract_starknet branch November 26, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants