{"id":29089599,"url":"https://github.com/openzeppelin/koba","last_synced_at":"2025-06-28T04:04:13.132Z","repository":{"id":240247802,"uuid":"802089613","full_name":"OpenZeppelin/koba","owner":"OpenZeppelin","description":"Deploy Stylus contracts with Solidity constructors","archived":false,"fork":false,"pushed_at":"2025-02-24T22:04:55.000Z","size":219,"stargazers_count":18,"open_issues_count":2,"forks_count":3,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-06-17T06:48:12.399Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenZeppelin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T13:58:21.000Z","updated_at":"2025-04-04T03:35:19.000Z","dependencies_parsed_at":"2024-06-01T20:17:31.898Z","dependency_job_id":"507b6159-d9d8-4379-a56c-9dcf4dc3268e","html_url":"https://github.com/OpenZeppelin/koba","commit_stats":null,"previous_names":["alexfertel/koba","openzeppelin/koba"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/OpenZeppelin/koba","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenZeppelin%2Fkoba","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenZeppelin%2Fkoba/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenZeppelin%2Fkoba/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenZeppelin%2Fkoba/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenZeppelin","download_url":"https://codeload.github.com/OpenZeppelin/koba/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenZeppelin%2Fkoba/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262371684,"owners_count":23300595,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-28T04:04:11.346Z","updated_at":"2025-06-28T04:04:13.123Z","avatar_url":"https://github.com/OpenZeppelin.png","language":"Rust","readme":"# koba (工場)\n\nGenerate deployment transaction data for Stylus contracts.\n\n\u003e [!WARNING]\n\u003e This project is still in a very early and experimental phase. It has never\n\u003e been audited nor thoroughly reviewed for security vulnerabilities. Do not use\n\u003e in production.\n\u003e\n\u003e This project is meant to be temporary. The problem it solves should be fixed\n\u003e by either `cargo-stylus` itself or in the Stylus VM. As such, we maintain this\n\u003e on a best-effort basis.\n\n## Why?\n\nDeployment transactions in Ethereum are composed of three sections:\n\n- A `prelude` - The bytecode prefix whose execution gets triggered by the\n  deployment transaction.\n- A `runtime` - The bytecode of the smart contract stored on-chain.\n- Constructor arguments - ABI-encoded arguments received by the constructor.\n\nDeployment transactions with an input of only compressed wasm are not yet\nsupported in Stylus. That is, only the `runtime` is actual webassembly.\n\nMoreover, the prelude of deployment transactions using `cargo-stylus` is\n[hard-coded].\n\n`koba` allows using a Solidity constructor alongside Stylus contracts, enabling\nusers to deploy their code in a familiar way.\n\n`koba` can be used both as a CLI tool or as a library in Rust projects. For a\nusage example beyond the section below, check out\n[OpenZeppelin Contracts for Stylus][stylus contracts].\n\n[hard-coded]: https://github.com/OffchainLabs/cargo-stylus/blob/be9faca7720b534de7ec210fa5a071eae79824ec/check/src/deploy.rs#L102-L114\n[stylus contracts]: https://github.com/OpenZeppelin/rust-contracts-stylus\n\n## Installation\n\nTo install `koba` on your machine, just run:\n\n```terminal\ncargo install koba\n```\n\nCompiling Solidity code with `koba` requires `solc` to be installed and\navailable through the command line.\n\nYou can also use `koba` as a library by adding it to your project using\n`cargo add koba`.\n\n## Usage\n\nYou can use the command-line interface in two ways: the `generate` and the\n`deploy` commands.\n\n### `koba generate`\n\nFor a contract like this:\n\n```rust\nsol_storage! {\n    #[entrypoint]\n    pub struct Counter {\n        uint256 number;\n    }\n}\n\n#[external]\nimpl Counter {\n    pub fn number(\u0026self) -\u003e U256 {\n        self.number.get()\n    }\n\n    pub fn increment(\u0026mut self) {\n        let number = self.number.get();\n        self.set_number(number + U256::from(1));\n    }\n}\n```\n\nWith a constructor like this:\n\n```solidity\ncontract Counter {\n    uint256 private _number;\n\n    constructor() {\n        _number = 5;\n    }\n}\n```\n\nthe following command outputs the transaction data you would need to send to\ndeploy the contract.\n\n```sh\n$ koba generate --sol \u003cpath-to-constructor\u003e --wasm \u003cpath-to-wasm\u003e\n6080604052348015600e575f80fd5b...d81f197cb0f070175cce2fd57095700201\n```\n\nYou can then use `cast` for example to deploy and activate the contract, like\nthis:\n\n```sh\n# Deploy the contract.\ncast send --rpc-url https://sepolia-rollup.arbitrum.io/rpc --private-key \u003cprivate-key\u003e --create \u003ckoba output\u003e\n\n# Activate the contract.\ncast send --rpc-url https://sepolia-rollup.arbitrum.io/rpc --private-key \u003cprivate-key\u003e --value \"0.0001ether\" 0x0000000000000000000000000000000000000071 \"activateProgram(address)(uint16,uint256)\" \u003ccontract address\u003e\n\n# Interact with the contract\ncast call --rpc-url https://sepolia-rollup.arbitrum.io/rpc \u003ccontract address\u003e \"number()\"\n0x0000000000000000000000000000000000000000000000000000000000000005\n\ncast send --rpc-url https://sepolia-rollup.arbitrum.io/rpc --private-key \u003cprivate-key\u003e \u003ccontract address\u003e \"increment()\"\n\ncast storage --rpc-url https://sepolia-rollup.arbitrum.io/rpc \u003ccontract address\u003e 0\n0x0000000000000000000000000000000000000000000000000000000000000006\n```\n\n### `koba deploy`\n\nFor the same code in the above section, you can instead just run `koba deploy`\nwith the appropriate arguments to deploy and activate your Stylus contract in\none go:\n\n```sh\n$ koba deploy --sol \u003cpath-to-constructor\u003e --wasm \u003cpath-to-wasm\u003e --args \u003cconstructor-arguments\u003e -e https://sepolia-rollup.arbitrum.io/rpc --private-key \u003cprivate-key\u003e\nwasm data fee: Ξ0.000113\ninit code size: 20.8 KB\ndeploying to RPC: https://sepolia-rollup.arbitrum.io/rpc\ndeployed code: 0x470AE56DFbea924722423926782D8aB30f108A49\ndeployment tx hash: 0xb52a68b973fb883dbef6bf3e0cbee4f02608ae71ad5a89f6a2f0c9f094242a5b\nactivated with 2987042 gas\nactivation tx hash: 0x40086445e80365b648621fd62d978d716708fe05144f303baa620086eda854d1\nsuccess!\n```\n\n## Limitations\n\n- `immutable` variables - `koba` currently does not support Solidity's\n  `immutable` variables, since there is no equivalent mechanism for Stylus.\n- `MCOPY` - Version [`0.8.24`][mcopy] of Solidity introduced the `MCOPY` opcode\n  from `EIP-5656`. As of 2024-05-28, `nitro-testnode` does not support this\n  opcode.\n\n[mcopy]: https://github.com/ethereum/solidity/releases/tag/v0.8.24\n\n## Why koba\n\n`koba` means [factory](https://jisho.org/search/%E5%B7%A5%E5%A0%B4) in Japanese\n-- the factory where a stylus gets assembled.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzeppelin%2Fkoba","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenzeppelin%2Fkoba","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzeppelin%2Fkoba/lists"}