Provides interactions with the NEO blockchain to .NET Core applications. Designed for dependency injection and convention based configuration. Integrates fully with ASP.NET Core Razor Pages and MVC web applications.
- .NET Core DI Service
- Minimal required configuration
- Supports configuration via
appsettings.json
- Query NEO and GAS wallet balance
- Query wallet transactions
- Query current block height
- Query best current node
- Generate new wallet private keys
- Ensure you have the latest .NET Core SDK installed
- Clone this repository
cd .\Neo.AspNetCore\Neo.AspNetCore.Demo\
dotnet restore
dotnet run
- Connect a browser to localhost on the specified port
- Edit some code in VS Code or VS Community Edition
- Acquire NuGet package for
Neo.AspNetCore
(TBC) - Set
MainNet
orTestNet
in configuration (See Examples), or during run-time withNeoService.SetNetwork()
- Call
services.AddNeo(Configuration)
in yourConfigureServices()
method withinStartup.cs
- Optional: Add
@using Neo.AspNetCore
to_ViewImports.cshtml
to ensure all extension methods are available in all views - See Examples for usage
Configuration in appsettings.json
:
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
},
"Neo": {
"Network": "TestNet"
}
}
Get the NEO balance from a wallet's public address:
@inject INeoService Neo
@{
var response = Neo.GetBalance("<public wallet address>");
}
<ul>
<li><strong>Address:</strong> @response.Address</li>
<li><strong>NEO:</strong> @response.Neo.Balance</li>
<li><strong>GAS:</strong> @response.Gas.Balance</li>
<li><strong>Network: </strong> @response.Net</li>
</ul>
Generate a new wallet private key, check its balance, and resolve the public key:
@inject INeoService Neo
@{
var key = Neo.GeneratePrivateKey();
var response = Neo.GetBalance(key.ToAddress());
}
<ul>
<li><strong>Private Key:</strong> @key.PrivateKey.ToHexString()</li>
<li><strong>Address:</strong> @response.Address</li>
<li><strong>NEO:</strong> @response.Neo.Balance</li>
<li><strong>GAS:</strong> @response.Gas.Balance</li>
<li><strong>Network: </strong> @response.Net</li>
</ul>
- Get NEP-5 token balances
- Custom token/asset definitions via configuration
- Implement additional wallet API end points
- Implement
ClaimsResponse
claims collection - Create a
dotnet new
template - Tutorials and examples
- Implement RPC layer
- Allow creating NEO and GAS transactions
- Allow claiming GAS
- Integrate with .NET Core
Identity
to allow streamlined individual user account wallets - Invoke smart contracts
- Retrieve smart contract storage data
- Test suite
Use, testing, suggestions, issues, and pull requests always welcome.
- Open Source MIT