Channel some Ki with Lua scripts for sending transactions to Starknet, powered by Rust.

Overview

Kipt

Kipt is leveraging the simplicity of Lua scripts to manage Starknet contracts using starknet-rs under the hood. With few lines, you can declare, deploy, invoke and call contracts.

The main focus of Kipt is to be used in the CI, without the need to write bash script using Cast from Starknet Foundry or Starkli.

Under the hood, Kipt is using starknet-rs to interact with Starknet.

Please take 5 min to read the book here, it's short and very helpful to get started!

Lua, an other language to learn?

You don't know Lua? No problem at all, it's a very small and easy scripting language, beginner guide here and full documentation here. And to use Kipt, you only need to know very few element of the language.

If you prefer a short cheatsheet, go here or here.

(For those who have already written an add-on for a famous MMO, welcome home!)

Quick start

To test Kipt, the easiest way is:

  1. Install Kipt
# 1. Install
curl https://raw.githubusercontent.com/glihm/kipt/main/kiptup/install | sh
source ~/.bashrc
kiptup
  1. Create a simple "demo.lua" script copying the example below, replacing with the name of your contract.
  2. Spin up katana in an other terminal.
  3. Run kipt --lua ./demo.lua.

Example

RPC = "KATANA"
ACCOUNT_ADDRESS = "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973"
ACCOUNT_PRIVKEY = "0x1800000000300000180000000000030000000000003006001800006600"

-- No args -> kipt.out
local logger = logger_init()

local decl_res, err = declare(
    "mycontract",
    { watch_interval = 300, artifacts_path = "./target/dev" }
)

if err then
  print(err)
  os.exit(1)
end

print("Declared class_hash: " .. decl_res.class_hash)

-- Deploy with no constructor args.
local depl_res, err = deploy(decl_res.class_hash, {}, { watch_interval = 300, salt = "0x1234" })

if err then
  print(err)
  os.exit(2)
end

local contract_address = depl_res.deployed_address
print("Contract deployed at: " .. contract_address)

-- Invoke to set a value.
local invk_res, err = invoke(
   {
      {
         to = contract_address,
         func = "set_a",
         calldata = { "0x1234" },
      },
   },
   { watch_interval = 300 }
)

if err then
  print(err)
  os.exit(3)
end

print("Invoke TX hash: " .. invk_res.tx_hash)

local call_res, err = call(contract_address, "get_a", {}, {})
print_str_array(call_res)
Comments
  • Check if contract is already declared to avoid contract errror

    Check if contract is already declared to avoid contract errror

    Currently, if a contract is already declared the declare command returns the expected Contract error from the blockchain. We can first check on chain if the contract is already declared. If yes, return Ok with the class_hash without error.

    Add a field in the response with already_declared set to true or false.

    opened by glihm 2
  • Contract class and address label

    Contract class and address label

    In order to ease how contract classes and addresses are logged, add a way in options for the user to label the classes / addresses for a more comprehensive logging.

    opened by glihm 1
  • RPC must be set does not stop the script

    RPC must be set does not stop the script

    When no RPC is provided, and the user attempts to make a call, an error is returned saying RPC must be set.

    Do we want to consider stopping the script execution if a such important variable is missing? This would be better for the dX.

    question 
    opened by glihm 0
  • Auto-log by the rust code and output markdown format

    Auto-log by the rust code and output markdown format

    The idea is that without any action the user can access a summary of every on-chain action. This can be outputted in a file in markdown format, that will also be useful to be displayed on summary for GitHub action.

    Each rust function sending a TX (declare, deploy, invoke) must be traced in this file. The calls may also be outputted.

    opened by glihm 0
  • Add a tx watcher in Lua

    Add a tx watcher in Lua

    Sometimes, users may not want to user the watch_interval. Having a Tx watcher can make them configure how they want the waiting.

    Also, we can accept an array-like, in order to watch several txs like a join for threading.

    watch_tx("tx_hash", interval_ms);
    
    watch_txs({ "tx_hash1", "tx_hash2" }, interval_ms);
    
    • [x] Single watcher
    • [ ] Multi watcher
    opened by glihm 1
  • Fix the artifacts locate function

    Fix the artifacts locate function

    The artifacts locate function https://github.com/glihm/kipt/blob/main/src/declare.rs#L181 has for now two problems:

    1. The recursion is not well made and then only parse the first sub-directory only.
    2. The path in the Lua file is relative to where kipt is executed. We need better error message to indicate that the file is not found because of paths.
    bug 
    opened by glihm 0
  • Kipt-action for GitHub

    Kipt-action for GitHub

    Kipt-action in order to ease the integration in CI pipelines.

    Docker action should be fine as we don't need cleanup. Don't forget to output the log file at the end to have a trace of deployed/declared contracts.

    opened by glihm 0
  • Dry run with a fork

    Dry run with a fork

    The idea is that the user may decide to run a dry-run to check that every transaction is run correctly.

    This may be done with Katana crate used locally, or even devnet when ready, to run all the script against the forked network.

    If everything runs fine -> then use the RPC mentioned by the user.

    opened by glihm 0
  • Possibility to include an other lua script

    Possibility to include an other lua script

    Some users may split the lua scripts in different directories and then have a master script to execute it all.

    RPC=...
    ACCOUNT=...
    PRIVKEY=...
    
    declare(...)
    deploy(...)
    
    -- Variables RPC/ACCOUNT/PRIVKEY will be still valid as they belong to globals.
    include("/path/contract2.lua")
    
    -- ...
    
    enhancement 
    opened by glihm 0
Releases(v0.1.3)
Starknet Stack let's you easily create new Cairo Starknet chains with their own sequencers, provers and verifiers

Starknet Stack flowchart LR A("Client") ==>|"Starknet Transactions"| subGraph0["Sequencer"] subGraph0 -.->|"Blocks with txs"| 300319["Watcher prover

Lambdaclass 7 Jul 11, 2023
🥷🩸 Madara is a ⚡ blazing fast ⚡ Starknet sequencer, based on substrate, powered by Rust 🦀

Report a Bug - Request a Feature - Ask a Question ⚡ Madara: Starknet Sequencer on Substrate ?? Welcome to Madara, a blazing fast ⚡ Starknet sequencer

Keep StarkNet Strange 138 Apr 22, 2023
🐺 Starknet Rust types 🦀

types-rs ?? Starknet Rust types ?? This repository is an initiative by a group of maintainers to address the fragmentation in the Starknet Rust ecosys

Starknet 22 Jun 2, 2023
Exploratory work on abigen in rust for Starknet 🦀

Starknet abigen for rust bindings This exploratory work aims at generating rust bindings from a contract ABI. Before the first release, we are termina

null 9 Sep 11, 2023
Kraken is a Starknet modular decentralized sequencer implementation.

Lambda Starknet Sequencer A Starknet decentralized sequencer implementation. Getting started The objective of this project is to create an L2 decentra

Lambdaclass 10 Jun 25, 2023
Blazing fast toolkit for developing Starknet contracts.

Starknet Foundry Blazingly fast toolkit for developing Starknet contracts designed & developed by ex Protostar team from Software Mansion based on nat

Foundry 149 Aug 1, 2023
Rust project for working with ETH - Ethereum transactions with Rust on Ganache and also deploy smart contracts :)

Just a test project to work with Ethereum but using Rust. I'm using plain Rust here, not Foundry. In future we will use Foundry. Hope you're already f

Akhil Sharma 2 Dec 20, 2022
A runtime for Yarn Spinner scripts, written in Rust.

yarn_spool yarn_spool is a runtime for Yarn Spinner scripts, written in Rust. Note that this library does not provide tools for parsing Yarn scripts,

Joe Clay 3 Dec 21, 2022
A Software Development Kit (SDK) for Zero-Knowledge Transactions

Aleo SDK The Aleo SDK is a developer framework to make it simple to create a new account, craft a transaction, and broadcast it to the network. Table

Aleo 270 Jan 5, 2023
Scans the Ethereum network for USDT ERC-20 token transfer transactions

ethscan This is a Rust command line program for scanning the Ethereum blockchain for USDT transfers within a time span and amount span. prerequisites

Frank Buss 4 Oct 6, 2022
Nym provides strong network-level privacy against sophisticated end-to-end attackers, and anonymous transactions using blinded, re-randomizable, decentralized credentials.

The Nym Privacy Platform The platform is composed of multiple Rust crates. Top-level executable binary crates include: nym-mixnode - shuffles Sphinx p

Nym 653 Dec 26, 2022
Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transactions of your non-custodial wallets on a provider of your choice, all while respecting your privacy

Bitcoin Push Notification Service (BPNS) Description Bitcoin Push Notification Service (BPNS) allows you to receive notifications of Bitcoin transacti

BPNS 1 May 2, 2022
The Light Protocol program verifies zkSNARK proofs to enable anonymous transactions on Solana.

Light Protocol DISCLAIMER: THIS SOFTWARE IS NOT AUDITED. Do not use in production! Tests cd ./program && cargo test-bpf deposit_should_succeed cd ./pr

null 36 Dec 17, 2022
A tool to help with estimating NEAR gas spent by transactions on Aurora.

Aurora Gas Estimator A tool to help with estimating NEAR gas spent by transactions on Aurora. Building from source Prerequisites Rust GNU Make (3.81+)

Michael Birch 4 Aug 23, 2022
Fiddi is a command line tool that does the boring and complex process of checking and processing/watching transactions on EVM compatible Blockchain.

Fiddi is a command line tool that does the boring and complex process of checking and processing/watching transactions on EVM compatible Blockchain.

Ahmad Abdullahi Adamu 7 Jan 9, 2023
A package that has a collection of unspent p2wsh bitcoin transactions.

P2WSH-UTXO A package that has a collection of unspent p2wsh transactions. Useful to see what are potential unspent multisig transactions. Library Crea

Tony Giorgio 3 Oct 22, 2022
hello-world geyser plugin to stream accounts and transactions from a solana node

src/lib.rs: entrypoint src/plugin.rs: main plugin code to run: cargo build && solana-test-validator -r --geyser-plugin-config config.json note: make s

null 4 Nov 18, 2022
Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.

stress4844 Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844 blobs. ca

Paradigm 50 Jan 4, 2023
Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer

Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.

Paradigm 50 Jan 4, 2023