GithubHelp home page GithubHelp logo

ftupas / nile-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openzeppelin/nile-rs

0.0 0.0 0.0 408 KB

CLI tool to develop StarkNet projects written in Cairo

License: MIT License

Rust 100.00%

nile-rs's Introduction

OpenZeppelin | Nile โ›ต - Rust version

Coverage Status Tests and linter

Overview

Nile is a CLI tool to develop or interact with StarkNet projects written in Cairo. This is an ongoing effort to migrate the existing tool written in Python to Rust, for compatibility with the new Cairo1 compiler.

Feature parity

For the current status of the features migration from Python check this page.

Testing features

Installation

Nile-rs is a rust binary application, and while we plan to improve the distribution mechanism, for the sake of simplicity, currently you need to manually build the package using cargo. Follow this guide to install rust on your machine if you haven't.

  1. Clone the repository and build the binary file from the main branch.

    cargo build --release
    
  2. Copy the executable into a directory under your system PATH.

    cp target/release/nile-rs /replace/with/dir/under/path
    
  3. Open a terminal and run the help command to check the installation.

    nile-rs --help
    

Quick Start

  1. Change dir into an empty directory.

    mkdir nile_project && cd nile_project
    
  2. Quickly setup a new project using init.

    nile-rs init
    
    ๐Ÿ—„  Creating project directory tree
    โ›ต๏ธ  Nile project ready!
    
    Try running: `nile-rs compile`
    
  3. Update the project name in ./Scarb.toml from nile_project to test in line 2.

  4. Compile the HelloStarknet contract (cairo 1 version) under src, with the compile command (using scarb under the hood).

    nile-rs compile
    
    Compiling test v0.1.0 (./Scarb.toml)
    Finished release target(s) in 0 seconds
    
  5. Run a valid devnet node to test the interaction.

    Currently, you need to use the version v0.5.0a1 starknet-devnet (a pre-release), passing the right compiler on initialization (v1.0.0-alpha.6). This will change very soon, so keep in mind you may need to tweak the setup a bit.

    pip install starknet-devnet==v0.5.0a1
    
    starknet-devnet --cairo-compiler-manifest /PATH/TO/COMPILER/CARGO/TOML/FILE
    
  6. Declare the contract.

    If this command fails with an unexpected error, you are probably using the wrong version of starknet-devnet and/or the compiler. We will work on improving the error feedback in the future.

    nile-rs declare test_HelloStarknet -d 0
    
    โณ Declaration successfully sent!
    
    Transaction hash: 0x...
    Class hash: 0x...
    

    Notice the -d 0 argument, this makes nile use the first predeployed account from the devnet node.

  7. Check the status of the transaction with the status command. We could have used the --track flag when declaring for waiting for the transaction to be confirmed.

    nile-rs status [tx_hash]
    
    Querying the status...
    โœ… Transaction status: AcceptedOnL2
    
  8. Deploy the contract.

    nile-rs deploy test_HelloStarknet -d 0 -t
    
    โณ Deployment successfully sent!
    
    Transaction hash: 0x...
    Contract address: 0x...
    Querying the status...
    โœ… Transaction status: AcceptedOnL2
    

    Notice the -t flag for tracking the status.

  9. Query the contract to get current the balance.

    nile-rs raw-call [contract_address] get_balance
    
    CallContractResult {
    result: [
            FieldElement {
                inner: 0x0000000000000000000000000000000000000000000000000000000000000000,
            },
        ],
    }
    

    We will improve the output of the raw-call (and change the command to call), after implementing a deserializer from ABI types.

  10. Send a transaction to increase the balance.

    nile-rs send --address [contract_address] increase_balance 5 -d 0 -t
    
    โณ Transaction successfully sent!
    
    Transaction hash: 0x...
    Querying the status...
    โœ… Transaction status: AcceptedOnL2
    
  11. Check the balance again.

    nile-rs raw-call [contract_address] get_balance
    
    CallContractResult {
    result: [
            FieldElement {
                inner: 0x0000000000000000000000000000000000000000000000000000000000000005,
            },
        ],
    }
    

License

Nile is released under the MIT License.

nile-rs's People

Contributors

ericnordelo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.