Skip to content
/ kipt Public

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

Notifications You must be signed in to change notification settings

glihm/kipt

Repository files navigation

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 = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03"
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)

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published