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

docs: compile, deploy and interact contracts on starknet-devnet-rs using starkli #23

Merged
merged 14 commits into from
Jul 25, 2024

Conversation

rnbguy
Copy link
Member

@rnbguy rnbguy commented Jul 22, 2024

Closes #1
Closes #4

Rendered

@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch from 691add1 to f8f79f8 Compare July 22, 2024 15:07
README.md Outdated Show resolved Hide resolved
@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch from f8f79f8 to ad0745f Compare July 22, 2024 16:32
@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch 2 times, most recently from 5c4d207 to 57741fd Compare July 22, 2024 16:35
@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch from 57741fd to 1666125 Compare July 22, 2024 16:36
@rnbguy rnbguy changed the title docs: deploy contracts via starknet-devnet-rs docs: compile, deploy and interact contracts on starknet-devnet-rs using starkli Jul 23, 2024
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@soareschen
Copy link
Collaborator

Thanks for the detailed documentation! Actually, we can also put the documentation on Notion, if it makes it easier to write and keep updated. Sorry for not being clear earlier.

For proper documentation, we can do it a bit later once the projects are properly setup. We will also try to automate the steps in the future using Nix and Rust, so that there are less manual steps to take.

@rnbguy
Copy link
Member Author

rnbguy commented Jul 24, 2024

Ah. I still like to keep this at docs/ as I look at Github more than Notion for engineering stuff. I can still create a notion page for continuous updates.

@rnbguy
Copy link
Member Author

rnbguy commented Jul 24, 2024

One thing I noticed, starkli call doesn't support --block-number to read data from previous blocks.(I was not using latest version) Also, I couldn't find a way to dump the starkli outputs in JSON.

The other tool library, I liked, is starknetjs. Although, it is a typescript package and not a command line tool, using it through deno is simple.

$ docker network create starknet-network
$ docker run --rm --network starknet-network --name starknet.devnet shardlabs/starknet-devnet-rs --seed=0 --accounts=3 --state-archive-capacity=full
$ docker run --rm --network starknet-network denoland/deno eval -q '
import { RpcProvider } from "npm:starknet";
console.log(await new RpcProvider({ nodeUrl: "http://starknet.devnet:5050" }).getBlockNumber());
'
0

This may be useful if we are writing CI automation scripts.

@soareschen
Copy link
Collaborator

I think we don't need to worry about automation and formatting for now. The use of starkli is a starting point. Since it is written in Rust and is using starknet-rs, it will be quite easy to use the library underneath to directly implement the automation and integration tests in Hermes SDK. The current documentation is more for our own reference, so that we can get things working manually while the automation is implemented.

Ah. I still like to keep this at docs/ as I look at Github more than Notion for engineering stuff. I can still create a notion page for continuous updates.

No problem to keep it on GitHub only, fee free to use the best approach you see fit.

docs/README.md Outdated
starkli call <CONTRACT_ADDRESS> get # prints 0x811
```

### Passing complex-typed inputs to the contract
Copy link
Collaborator

Choose a reason for hiding this comment

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

So it looks like we cannot really rely on starkli to interact with more complex contracts. I will work on the Hermes client so that we can use that instead to interact with the contracts we written.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, looks like that. I added more instructions to transfer funds for ERC20 contracts. They work - but requires value serialization.

Copy link
Member Author

@rnbguy rnbguy Jul 24, 2024

Choose a reason for hiding this comment

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

The type information is stored in the compiled .contract_class.json and it can be fetched from a starknet node.

The way I see, starkli should do something like grpcurl to (de)serialize the input and output values dynamically. grpcurl uses reflection to parse/format from/to JSON string to/from proto encoding.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a tool exactly for this --- cainome It's like protoc with tonic.

$ cargo install --features=build-binary --git https://github.com/cartridge-gg/cainome
$ mkdir codegen
$ cainome --output-dir gen --contract-name erc20 --execution-version v3 --contract-address 0x49D36570D4E46F48E99674BD3
FCC84644DDD6B96F7C741B1562B82F9E004DC7 --rpc-url http://127.0.0.1:5050 --rust 

@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch 3 times, most recently from a1bdea9 to 12872a2 Compare July 24, 2024 17:28
@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch from 12872a2 to c87514e Compare July 24, 2024 17:34
@rnbguy rnbguy force-pushed the rano/devnet-spawn-guide branch from 1f4c76a to 3f89a6a Compare July 25, 2024 10:46
@rnbguy rnbguy marked this pull request as ready for review July 25, 2024 10:46
@rnbguy
Copy link
Member Author

rnbguy commented Jul 25, 2024

I think that the document is a good position now. We can merge it. Let me know if it is better to break the README into multiple markdowns.

@soareschen
Copy link
Collaborator

Awesome, looks great! Let's merge it and move on to other work. Remember that this is mainly internal documentation for us to get started with the development more quickly. So we don't need to be too comprehensive.

@soareschen soareschen merged commit b2d1e16 into main Jul 25, 2024
@soareschen soareschen deleted the rano/devnet-spawn-guide branch July 25, 2024 17: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.

Document how to perform basic token transfer Document steps to run a local devnet using starknet-devnet-rs
2 participants