Skip to content

feat(tck): implement createContract JSON-RPC method - #2611

Open
exploreriii wants to merge 11 commits into
hiero-ledger:mainfrom
exploreriii:feat/tck-create-contract
Open

feat(tck): implement createContract JSON-RPC method#2611
exploreriii wants to merge 11 commits into
hiero-ledger:mainfrom
exploreriii:feat/tck-create-contract

Conversation

@exploreriii

@exploreriii exploreriii commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #2594

Implements the createContract JSON-RPC method: CreateContractParams, handler wrapping ContractCreateTransaction (setter order matching the JS TCK server), CreateContractResponse, and a shared decode_hex util (0x-tolerant, strict) that the upcoming contract-service methods will reuse.

TCK results (local solo, TCK v0.12.0): 114 passing, 0 failing, 7 pending on the ContractCreateTransaction suite. All pendings are known-unimplemented methods tracked separately: appendFile (#2493), deleteFile (#2492).

BREAKING CHANGES: ContractCreateTransaction no longer pre-validates client-side:

  • Missing bytecode source / gas now surfaces as the network's CONTRACT_BYTECODE_EMPTY / INSUFFICIENT_GAS instead of a local ValueError — the TCK spec explicitly tests for the network responses, and sibling SDKs behave this way. The network would not have let these pass anyway.
  • set_gas() now raises ValueError on negative gas (JS SDK parity; required by the TCK driver's negative-gas tests, and a negative gas could never succeed on-network).
  • set_bytecode_file_id() now clears bytecode (and vice versa), keeping the protobuf initcodeSource oneof consistent instead of letting kwarg order silently decide.

…andled by network

Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
…guity

Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
… raise

Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
…mance. A negative gas could never have succeeded on-network

Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
@github-actions github-actions Bot added approved Issue has been approved by team member lang: python Uses Python programming language scope: TCK involves engineering for the implementation of TCK method and module skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples labels Aug 26, 2026
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2611   +/-   ##
=======================================
  Coverage   95.44%   95.44%           
=======================================
  Files         165      165           
  Lines       10562    10567    +5     
=======================================
+ Hits        10081    10086    +5     
  Misses        481      481           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@exploreriii exploreriii changed the title Feat/tck create contract feat(tck): implement createContract JSON-RPC method Aug 26, 2026
@exploreriii
exploreriii marked this pull request as ready for review August 26, 2026 19:21
@exploreriii
exploreriii requested review from a team as code owners August 26, 2026 19:21
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

Next included review available in 37 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 66eea751-5022-4ebf-9b80-060b7647d908

📥 Commits

Reviewing files that changed from the base of the PR and between ac8e5b4 and 53dd86c.

📒 Files selected for processing (5)
  • src/hiero_sdk_python/contract/contract_create_transaction.py
  • tck/handlers/contract.py
  • tck/util/param_utils.py
  • tests/tck/contract_handler_test.py
  • tests/unit/contract_create_transaction_test.py

Walkthrough

The PR adds the createContract JSON-RPC method, its parameter and response models, hexadecimal decoding, handler registration, and unit tests. It also changes SDK contract creation to defer missing bytecode and gas validation to the network.

Changes

Contract creation

Layer / File(s) Summary
SDK contract creation behavior
src/hiero_sdk_python/contract/contract_create_transaction.py, tests/unit/contract_create_transaction_test.py
The SDK rejects negative gas, clears alternate bytecode sources, and permits missing bytecode or gas during protobuf construction.
TCK parameters and transaction mapping
tck/param/contract.py, tck/util/param_utils.py, tck/response/contract.py, tck/handlers/contract.py
The TCK adds contract creation models, hexadecimal decoding, contract field mapping, and bytecode-source precedence.
RPC registration and execution
tck/handlers/__init__.py, tck/handlers/contract.py, tests/tck/contract_handler_test.py
The handler is registered, executes the transaction, validates the receipt, returns the contract ID and status, and is covered by unit tests.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Merge Risk: 🔵 Low · up to ac8e5

The PR adds the createContract method and changes contract-creation validation and oneof handling. It is mergeable with explicit owner follow-up because negative constructor gas, whitespace in hexadecimal input, and conflicting staking IDs can produce inconsistent validation or request behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant create_contract
  participant CreateContractParams
  participant ContractCreateTransaction
  participant Network
  Client->>create_contract: createContract request
  create_contract->>CreateContractParams: parse JSON parameters
  create_contract->>ContractCreateTransaction: apply contract fields
  create_contract->>Network: execute transaction
  Network-->>create_contract: receipt with contract ID and status
  create_contract-->>Client: CreateContractResponse
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.48% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: implementing the TCK createContract JSON-RPC method.
Description check ✅ Passed The description directly explains the createContract implementation, related transaction behavior changes, tests, and TCK results.
Linked Issues check ✅ Passed The changes satisfy issue #2594. They add and register createContract, define request and response models, support inline and file-based bytecode, decode hexadecimal values, apply transaction paramete…
Out of Scope Changes check ✅ Passed The transaction validation updates, handler registration, parameter and response models, utility, and tests all support the linked issue objectives. No unrelated code changes are identified.
Full details: Linked Issues check

Explanation

The changes satisfy issue #2594. They add and register createContract, define request and response models, support inline and file-based bytecode, decode hexadecimal values, apply transaction parameters, validate responses, and add tests. The described TCK suite results also support compliance. The excluded uv.lock file is not required for the issue objectives.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 443000ae-e8ae-478c-9b1d-84d2bd6d12bc

📥 Commits

Reviewing files that changed from the base of the PR and between e8ed509 and ac8e5b4.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • src/hiero_sdk_python/contract/contract_create_transaction.py
  • tck/handlers/__init__.py
  • tck/handlers/contract.py
  • tck/param/contract.py
  • tck/response/contract.py
  • tck/util/param_utils.py
  • tests/tck/contract_handler_test.py
  • tests/unit/contract_create_transaction_test.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread src/hiero_sdk_python/contract/contract_create_transaction.py
Comment thread tck/handlers/contract.py
Comment thread tck/util/param_utils.py
Comment thread tests/tck/contract_handler_test.py Outdated
@github-actions github-actions Bot added open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review labels Aug 26, 2026
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>

@aceppaluni aceppaluni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two thing from me:

Were the changes in uv.lock intentional?

Comment thread tck/handlers/contract.py
@exploreriii
exploreriii requested a review from aceppaluni August 27, 2026 09:55
Comment thread tck/handlers/contract.py
INT64_MAX = 2**63 - 1


def _require_int64(value: str, name: str) -> int:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we move this check to the sdk's CreateContractTransaction class. to handle this within the sdk by rasing OverflowError. Similar to the Uint256 datatype field in AccountCreateTransaction

@danielmarv danielmarv added status: update branch developer needs to click update branch status: Needs Developer Revision Author needs to apply suggested changes/improvements labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Issue has been approved by team member lang: python Uses Python programming language open to community review PR is open for community review and feedback queue:junior-committer PR awaiting initial quality review scope: TCK involves engineering for the implementation of TCK method and module skill: advanced requires knowledge of multiple areas in the codebase without defined steps to implement or examples status: Needs Developer Revision Author needs to apply suggested changes/improvements status: update branch developer needs to click update branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(tck): implement createContract JSON-RPC method

6 participants