Neo.SmartContract.Framework 3.10.2

Prefix Reserved
dotnet add package Neo.SmartContract.Framework --version 3.10.2
                    
NuGet\Install-Package Neo.SmartContract.Framework -Version 3.10.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Neo.SmartContract.Framework" Version="3.10.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Neo.SmartContract.Framework" Version="3.10.2" />
                    
Directory.Packages.props
<PackageReference Include="Neo.SmartContract.Framework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Neo.SmartContract.Framework --version 3.10.2
                    
#r "nuget: Neo.SmartContract.Framework, 3.10.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Neo.SmartContract.Framework@3.10.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Neo.SmartContract.Framework&version=3.10.2
                    
Install as a Cake Addin
#tool nuget:?package=Neo.SmartContract.Framework&version=3.10.2
                    
Install as a Cake Tool

Neo.SmartContract.Framework

The foundational framework for developing Neo smart contracts in C#. Provides essential types, attributes, and APIs for blockchain development.

Features

  • Smart Contract Base: SmartContract base class with core functionality
  • Native Contracts: Access to Neo native contracts (NeoToken, GasToken, etc.)
  • Cryptographic APIs: Hashing, encryption, and signature verification
  • Storage APIs: Persistent storage operations
  • Blockchain Access: Block and transaction information
  • Supported Standards: NEP-11, NEP-17, and other standard implementations

Installation

dotnet add package Neo.SmartContract.Framework

Quick Start

using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;
using Neo.SmartContract.Framework.Services;
using System.ComponentModel;
using System.Numerics;

namespace MyContract
{
    [DisplayName("MyToken")]
    [ContractAuthor("Your Name", "you@example.com")]
    [ContractDescription("My NEP-17 Token")]
    [ContractVersion("0.0.1")]
    [SupportedStandards(NepStandard.Nep17)]
    public class MyToken : Nep17Token
    {
        [Hash160("NXV7ZhHiyM1aHXwpVsRZC6BwNFP2jghXAq")]
        private static readonly UInt160 Owner = default!;

        public override string Symbol { [Safe] get => "MYT"; }
        public override byte Decimals { [Safe] get => 8; }

        public static void OnNEP17Payment(UInt160 from, BigInteger amount, object? data = null)
        {
            // Handle incoming payments
        }

        [Safe]
        public static bool IsOwner() => Runtime.CheckWitness(Owner);
    }
}

Core Components

Attributes

  • [DisplayName] - Set contract/method display name
  • [ContractAuthor], [ContractDescription], [ContractVersion] - Add metadata to contract manifest
  • [SupportedStandards] - Declare supported NEP standards
  • [Hash160], [InitialValue] - Initialize static fields
  • [Safe] - Mark methods as safe (no state changes)

Native Contracts

  • NeoToken - NEO token operations
  • GasToken - GAS token operations
  • ContractManagement - Contract deployment/management
  • CryptoLib - Cryptographic operations
  • StdLib - Standard library functions

Services

  • Storage - Key-value persistent storage
  • Runtime - Contract execution context
  • Blockchain - Block and transaction access
  • ExecutionEngine - Script execution utilities

Role-based pausing

Use PausableOwnable for a single owner's pause authority, or PausableAccessControl when multiple accounts need permission to pause and unpause. These are alternative authorization models; role-based pausing does not replace the owner-based model.

using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Attributes;

public class EmergencyContract : PausableAccessControl
{
    public static void _deploy(object data, bool update)
    {
        InitializePausableAccessControl((UInt160?)data, update);
    }

    [WhenNotPaused]
    public static bool DoWork() => true;

    [WhenPaused]
    public static bool InspectWhilePaused() => true;
}

On initial deployment, pass an administrator's script hash as deployment data, or null to use the transaction sender. The initializer grants that account both DEFAULT_ADMIN_ROLE() (0) and PAUSER_ROLE() (1). Other roles must use distinct identifiers: reusing 1 also grants pause authority.

The inherited GrantRole(PAUSER_ROLE(), admin, pauser) and RevokeRole(PAUSER_ROLE(), admin, pauser) manage pauser assignments. The acting administrator must hold the role's admin role and witness the invocation. Pause(pauser) and Unpause(pauser) likewise require both the pauser role and a valid witness for the supplied account; knowing a pauser's address is insufficient. Successful transitions emit Paused or Unpaused with the acting account.

The pause flag uses storage key 0xFE, matching the default pause modifiers, while access-control storage uses 0xFB. Do not reuse those prefixes for application storage. The modifiers only protect annotated methods; apply other authorization checks to sensitive application operations as appropriate.

Always forward the deployment callback's update argument to the initializer. When true, initialization is a no-op: it preserves the administrator, role assignments and pause state without regranting revoked roles. Contracts migrating from a different base class need their own authorized migration policy; the update path does not bootstrap missing roles.

With the default role-admin policy, if every pauser has been revoked, a default administrator can still grant PAUSER_ROLE() to itself or another account, then unpause with that account's witness. If a derived contract changes the pauser role's admin role, it must preserve an authorized recovery path.

Documentation

For comprehensive documentation and examples: https://github.com/neo-project/neo-devpack-dotnet/tree/master-n3/docs

License

MIT - See LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Neo.SmartContract.Framework:

Repository Stars
neo-project/examples
Version Downloads Last Updated
3.10.2 81 11/18/2026
3.10.1 2,601 7/23/2026
3.10.0 1,155 6/12/2026
3.9.1 1,809 1/28/2026
3.9.0 264 1/28/2026
3.8.1 1,944 5/12/2025
3.7.4.1 501 11/6/2024
3.7.4 2,008 5/20/2024
3.6.2 835 11/22/2023
3.6.0 629 9/13/2023
3.5.0 1,417 12/8/2022
3.4.0 1,128 8/5/2022
3.3.0 1,180 6/6/2022
3.1.0 2,177 11/14/2021
3.0.3 937 10/8/2021
3.0.2 874 8/6/2021
Loading failed