Skip to content

feat: Add Neo Smart Contract Solution template with unit tests#1502

Open
Jim8y wants to merge 9 commits intomaster-n3from
feature/template-solution-with-tests
Open

feat: Add Neo Smart Contract Solution template with unit tests#1502
Jim8y wants to merge 9 commits intomaster-n3from
feature/template-solution-with-tests

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 31, 2026

Summary

This PR adds a new solution template neocontract that creates a complete smart contract project structure with unit tests.

Changes

New Template: neocontract

Creates a solution with:

  • Contract Project: Smart contract with Neo.SmartContract.Framework 3.9.1
  • Unit Test Project: Test project with Neo.SmartContract.Testing 3.9.1
  • Solution File: Links both projects (GUIDs generated via template symbols)
  • Sample Code: Working smart contract with owner management + sample tests

Template Updates

  • Updated all templates from Neo 3.8.1-* to 3.9.1
  • Fixed nccs debug argument from -d to -d Extended for proper debug info
  • Added template test coverage for the solution template + generated artifacts
  • Aligned solution test namespace with sourceName replacement

Usage

dotnet new neocontract -n MyAwesomeContract
cd MyAwesomeContract
dotnet build MyAwesomeContract.UnitTests/MyAwesomeContract.UnitTests.csproj
dotnet test MyAwesomeContract.UnitTests/MyAwesomeContract.UnitTests.csproj

Verification

  • ✅ Solution template: Creates, builds, and tests pass
  • ✅ Contract templates (nep17, owner, oracle): Build and generate .nef/.manifest
  • ✅ Template unit tests: dotnet test tests/Neo.SmartContract.Template.UnitTests/Neo.SmartContract.Template.UnitTests.csproj

Files Added

  • src/Neo.SmartContract.Template/templates/neocontractsolution/ (8 new files)
  • tests/Neo.SmartContract.Template.UnitTests/templates/neocontractsolution/

Files Modified

  • Template version updates (3.8.1-* → 3.9.1)
  • Debug argument fix (-d → -d Extended)

Jim8y added 4 commits January 30, 2026 09:41
Add a new template 'neocontract' that creates a complete solution structure:
- Contract project with Neo.SmartContract.Framework and Analyzer packages
- Unit test project with Neo.SmartContract.Testing package
- Solution file linking both projects
- Sample smart contract with owner management functionality
- Sample test file with MSTest setup

The template uses NuGet package references (version 3.9.1) for all dependencies.
- Update all templates from Neo version 3.8.1-* to 3.9.1
- Fix nccs debug argument from '-d' to '-d Extended' for proper debug info generation
- Applied to neocontractnep17, neocontractowner, neocontractoracle, and neocontractsolution templates
public delegate void OnSetOwnerDelegate(UInt160 previousOwner, UInt160 newOwner);

[DisplayName("SetOwner")]
public static event OnSetOwnerDelegate OnSetOwner;
Copy link
Contributor

Choose a reason for hiding this comment

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

It's OK if the DisplayName of this event is SetOwner and there is a SetOwner method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it actually does not matter, but udpated anyway

@shargon
Copy link
Member

shargon commented Feb 1, 2026

ut fault

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants