Skip to content

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jul 9, 2025

Summary

This PR establishes the foundational deployment infrastructure for Neo smart contracts, providing a clean, extensible API for deployment operations.

Key Features

  • DeploymentToolkit class with basic deployment API structure
  • Network configuration support (mainnet, testnet, local, custom RPC)
  • WIF key support for transaction signing with validation
  • Comprehensive project structure with interfaces and models
  • Configuration management with JSON files and environment variables
  • 16 unit tests covering all basic functionality
  • Documentation updates with usage examples

Implementation Highlights

  • Interface-based design for excellent testability and modularity
  • Follows established .NET patterns and conventions
  • Comprehensive error handling and validation
  • Clean separation of concerns between models, services, and interfaces

Files Added

  • src/Neo.SmartContract.Deploy/ - Complete project structure
  • tests/Neo.SmartContract.Deploy.UnitTests/ - Comprehensive test suite
  • Updated solution file and README documentation

Dependencies

This PR has no dependencies and establishes the foundation for future deployment features.

Testing

  • ✅ All 16 unit tests pass
  • ✅ Solution builds successfully
  • ✅ No breaking changes to existing functionality

This PR creates a solid foundation that will be extended with full implementation in subsequent PRs.

erikzhang and others added 2 commits June 16, 2025 21:35
* SafeAttribute supports in properties

* Update Nep11Token.cs

* Safe setters are not allowed
- Add DeploymentToolkit class with basic deployment API
- Implement network configuration support (mainnet, testnet, local, custom RPC)
- Add WIF key support for transaction signing
- Create comprehensive project structure with interfaces and models
- Add configuration management with JSON and environment variable support
- Include 16 unit tests covering all basic functionality
- Update README.md with deployment documentation and usage examples

This establishes the foundation for Neo smart contract deployment capabilities
without implementation details, providing a clean base for future enhancements.
…rence

- Fix whitespace formatting issues in deployment toolkit files
- Add missing final newlines to all source files
- Remove duplicate Microsoft.NET.Test.Sdk package reference in test project
- All 16 unit tests continue to pass
- Code formatting now passes GitHub Actions checks
@Jim8y Jim8y force-pushed the pr1-core-deployment-framework branch from 2f05ca7 to ce28e18 Compare July 9, 2025 11:00
@Jim8y Jim8y force-pushed the pr1-core-deployment-framework branch from ce28e18 to ef94799 Compare July 9, 2025 11:06
/// <summary>
/// Network magic number for transaction signing
/// </summary>
public uint NetworkMagic { get; set; } = 894710606; // Default to testnet
Copy link
Member

Choose a reason for hiding this comment

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

Can this be retrieved from the rpc?

/// <summary>
/// Network name (private, testnet, mainnet)
/// </summary>
public string Network { get; set; } = string.Empty;
Copy link
Member

Choose a reason for hiding this comment

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

It depend to the RpcUrl, isn't it?

Comment on lines 27 to 32
<ItemGroup>
<Compile Update="**/*.cs">
<Pack>true</Pack>
<PackagePath>src</PackagePath>
</Compile>
</ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

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

That's required?

Jim8y added 8 commits July 9, 2025 21:07
- Remove Network property from NetworkConfiguration as it depends on RpcUrl
- Change NetworkMagic to nullable and retrieve from RPC when not configured
- Add logic to fetch NetworkMagic from RPC using GetVersionAsync()
- Remove unnecessary Compile Update section from csproj file
- Update unit tests to match new behavior
- Add tests to verify network magic can be retrieved from RPC
- Add tests for network configuration priority (specific > global > RPC)
- Add tests for SetNetwork with various inputs and edge cases
- Add tests to ensure proper RPC URL configuration for known networks
- Document expected network magic values for mainnet and testnet
- Change testnet RPC URL from testnet1.neo.coz.io to testnet.rpc.ngd.network
- Update all test assertions to use the new NGD testnet URL
- Add integration tests to verify RPC connectivity (skipped by default)
- Ensure network magic retrieval works with NGD testnet endpoint
- Change from testnet.rpc.ngd.network to testnet.ngd.network
- Update all test assertions to use the correct URL
- Change testnet RPC URL to http://seed2t5.neo.org:20332
- Update all test assertions to use the Neo seed node URL
- Update integration test names to reflect Neo testnet
Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

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

Hi @Jim8y

My suggestion is that if this is able to Deploy and test, so, the examples we have here should be deployed during tests and we could verify states.
That would be a good test that has a real flow behind.

On the other hand, I see some separation between this repo and the framework being pushed here.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 9, 2025

Hi @Jim8y

My suggestion is that if this is able to Deploy and test, so, the examples we have here should be deployed during tests and we could verify states. That would be a good test that has a real flow behind.

On the other hand, I see some separation between this repo and the framework being pushed here.

its hard to balance, smaller prs for easier to review, but lacks complete functionality, complete tookit too large for reviewing. yet if you wish to review as a whole, you can check the full pr. bellow is the deployed example contracts on testnet.

Latest Deployment (TestNet)

Contract Address Transaction Hash Network
TokenContract 0x2db2dce76b4a7f8116ecfae0d819e7099cb3a256 0x29397173e0e5ad93010f721ff6f786171e32e84f9bc44067072df332853e9554 TestNet
NFTContract 0x8699c5d074fc27cdbd7caec486387c1a29300536 0xc0b8c4b7dd68525da2adc39455252f32ac884947aeaba387c6ce20fa017952b7 TestNet
GovernanceContract 0xa3db58df3764610e43f3fda0c7b8633636c6c147 0x43d4a849396ddaf6b9917a3aeb30e49929a15fa32ebf51b1ab4b2d9e46dcf5a8 TestNet

Deployment Details:

  • Deployer Address: NTmHjwiadq4g3VHpJ5FQigQcD4fF5m8TyX (0x0c3146e78efc42bfb7d4cc2e06e3efd063c01c56)
  • Network: NEO TestNet
  • RPC Endpoint: https://testnet1.neo.coz.io:443
  • Total GAS Consumed: ~30.00233163 GAS
  • Deployment Mode: Multi-contract with dependencies

@vncoelho
Copy link
Member

vncoelho commented Jul 9, 2025

I see @Jim8y, but why this needed to be here in Devpack?
Isn't this focussed on the C# compiler.

What I see in this pr is like a framework for interacting with the blockchain.

@vncoelho
Copy link
Member

vncoelho commented Jul 9, 2025

I see @Jim8y, but why this needed to be here in Devpack? Isn't this focussed on the C# compiler.

What I see in this pr is like a framework for interacting with the blockchain.

Maybe even the Core itself is better than here

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 9, 2025

I see @Jim8y, but why this needed to be here in Devpack? Isn't this focussed on the C# compiler.
What I see in this pr is like a framework for interacting with the blockchain.

Maybe even the Core itself is better than here

implementing, testing, deploying is a complete workflow, with this, developer can do everfything easily all together. they dont need to download and install and sync neo-cli, or searching for some unknown deployment methods. All of these is for a better development experience.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jul 11, 2025

@shargon all your concern and suggestion have being resolved.

/// </summary>
public class DeploymentToolkit : IDisposable
{
private const string GAS_CONTRACT_HASH = "0xd2a4cff31913016155e38e474a2c06d08be276cf";
Copy link
Member

Choose a reason for hiding this comment

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

Take the hash from the NativeContract Instance?

/// <summary>
/// Wallet configuration settings
/// </summary>
public class WalletConfiguration
Copy link
Member

Choose a reason for hiding this comment

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

One class per file please

var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempDir);
var contractPath = Path.Combine(tempDir, "TestContract.cs");
File.WriteAllText(contractPath, contractCode);
Copy link
Member

Choose a reason for hiding this comment

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

The UT that create a file, should delete the file after the test

…ffolding; add DeploymentArtifactsDemo example; fix RpcStore OnNewSnapshot; docs update
{
if (!doCall)
{
if (string.IsNullOrEmpty(wif) || string.IsNullOrEmpty(nef) || string.IsNullOrEmpty(manifest))
Copy link
Member

Choose a reason for hiding this comment

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

if (string.IsNullOrWhiteSpace(wif) || string.IsNullOrWhiteSpace(nef) || string.IsNullOrWhiteSpace(manifest))

}
else
{
if (string.IsNullOrEmpty(contract) || string.IsNullOrEmpty(method))
Copy link
Member

Choose a reason for hiding this comment

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

if (string.IsNullOrWhiteSpace(contract) || string.IsNullOrWhiteSpace(method))

}

object[] callArgs = Array.Empty<object>();
if (!string.IsNullOrEmpty(argsJson))
Copy link
Member

Choose a reason for hiding this comment

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

if (!string.IsNullOrWhiteSpace(argsJson))

@shargon shargon changed the base branch from master to dev September 12, 2025 09:44
@shargon
Copy link
Member

shargon commented Sep 12, 2025

@Jim8y Could you solve the conflicts?

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.

5 participants