Generate SDK contract wrappers #1445

Open
opened 2025-12-28 17:16:28 +00:00 by sami · 4 comments
Owner

Originally created by @lock9 on GitHub (Dec 9, 2024).

I'm using the neotest package to test my smart contract and noticed the need to manually configure the hash and method names. This process is error-prone and reduces development efficiency. Neo Go already generates contract bindings, but these cannot be used with neotest.

Please consider adding support to generate an 'offchain' SDK.

Describe the solution you'd like

Enhance the generate-wrapper command to create 'offchain' contract bindings.

Describe alternatives you've considered

This feature is implemented in my TS SDK but generates TypeScript, not Go code.

Additional context

Adding this feature would save significant development time, reduce errors, and minimize frustration. It will enable auto-complete, preventing common issues such as incorrect method names, parameter counts, orders, and types. Return type conversion is also important, but may be harder to implement.

Don't forget to add labels!

  • CLI
  • feature
Originally created by @lock9 on GitHub (Dec 9, 2024). ## Is your feature request related to a problem? Please describe. I'm using the `neotest` package to test my smart contract and noticed the need to manually configure the hash and method names. This process is error-prone and reduces development efficiency. Neo Go already generates contract bindings, but these cannot be used with neotest. Please consider adding support to generate an 'offchain' SDK. ## Describe the solution you'd like Enhance the `generate-wrapper` command to create 'offchain' contract bindings. ## Describe alternatives you've considered This feature is implemented in my TS SDK but generates TypeScript, not Go code. ## Additional context Adding this feature would save significant development time, reduce errors, and minimize frustration. It will enable auto-complete, preventing common issues such as incorrect method names, parameter counts, orders, and types. Return type conversion is also important, but may be harder to implement. ## Don't forget to add labels! - CLI - `feature`
Author
Owner

@roman-khimov commented on GitHub (Dec 9, 2024):

We provide contract bindings that work via RPC (generate-rpcwrapper). But neotest is not RPC-based, so they can't be easily reused. Also, there is a question of these bindings usability specifically for testing, sometimes you want to make abnormal calls in tests and they can not provide this.

@roman-khimov commented on GitHub (Dec 9, 2024): We provide contract bindings that work via RPC (`generate-rpcwrapper`). But `neotest` is not RPC-based, so they can't be easily reused. Also, there is a question of these bindings usability specifically for testing, sometimes you want to make abnormal calls in tests and they can not provide this.
Author
Owner

@AnnaShaleva commented on GitHub (Dec 9, 2024):

But neotest is not RPC-based

BTW, we have https://github.com/nspcc-dev/neo-go/issues/3245 for that. But in general I agree, neotest is a testing tool, so we need to keep these non-contract-specific APIs anyway.

@AnnaShaleva commented on GitHub (Dec 9, 2024): > But neotest is not RPC-based BTW, we have https://github.com/nspcc-dev/neo-go/issues/3245 for that. But in general I agree, `neotest` is a testing tool, so we need to keep these non-contract-specific APIs anyway.
Author
Owner

@lock9 commented on GitHub (Dec 9, 2024):

We provide contract bindings that work via RPC (generate-rpcwrapper). But neotest is not RPC-based, so they can't be easily reused. Also, there is a question of these bindings usability specifically for testing, sometimes you want to make abnormal calls in tests and they can not provide this.

It generated the file correctly, but I don't know how to use it. Is there any example that I can check? (using a generated rpc file)

@lock9 commented on GitHub (Dec 9, 2024): >We provide contract bindings that work via RPC (generate-rpcwrapper). But neotest is not RPC-based, so they can't be easily reused. Also, there is a question of these bindings usability specifically for testing, sometimes you want to make abnormal calls in tests and they can not provide this. It generated the file correctly, but I don't know how to use it. Is there any example that I can check? (using a generated rpc file)
Author
Owner

@AnnaShaleva commented on GitHub (Dec 10, 2024):

Is there any example that I can check? (using a generated rpc file)

You can't use auto-generated RPC bindings with neotest because neotest doesn't work over RPC. But if you're looking for RPC bindings usage examples by their own, then it's a bit different story, the usage pattern is similar to Actor/Invoker pattern but with contract-specific methods:

@AnnaShaleva commented on GitHub (Dec 10, 2024): > Is there any example that I can check? (using a generated rpc file) You can't use auto-generated RPC bindings with `neotest` because `neotest` doesn't work over RPC. But if you're looking for RPC bindings usage examples by their own, then it's a bit different story, the usage pattern is similar to `Actor`/`Invoker` pattern but with contract-specific methods: * https://github.com/nspcc-dev/neo-go-sc-wrkshp?tab=readme-ov-file#step-1-5 contains a set of useful links to documentation * https://github.com/nspcc-dev/neo-go-sc-wrkshp/blob/master/dApp/rpc_wrapper/storage.go is an auto-generated RPC wrapper of a simple storage contract and https://github.com/nspcc-dev/neo-go-sc-wrkshp/blob/c0d3328aa423d84767eee4089fe47f47410c8fe0/dApp/dApp.go#L495 contains a tiny piece of example on how to use this wrapper * https://github.com/nspcc-dev/neo-go-sc-wrkshp/blob/c0d3328aa423d84767eee4089fe47f47410c8fe0/dApp/dApp.go#L266 contains examples of Actor/Invoker usages as far as native contract-specific bindings provided by NeoGo.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neo-go#1445
No description provided.