Welcome to the project! 🌍 Below are links to the README in various languages:
You need .NET Core SDK 8.0+ which provides the latest C# compiler and .NET VM. Read and follow the instruction to install .NET Core SDK on the .NET Core downloads page.
Make sure that your .NET Core SDK is 8.0 or higher. You could show the version you are using by dotnet --info
command.
dotnet build
"Action": {
"ActionLoaderType": "SampleAction.ActionLoader",
"ModulePath": "<absolute-path-to-the-dll>/SampleAction.dll"
}
Before running, set the ModulePath
to the absolute path of SampleAction.dll
built following the steps above.
dotnet run --project ./SampleNode/SampleNode.csproj
SampleNode is a Libplanet blockchain application example using Libplanet.Node. All actions are dealt with Bencodex's IValue
type.
This example consists of two projects:
- SampleAction: Implements the actions for application logic and the loader for those actions.
- SampleNode: Configures the application, incorporates the actions implemented in SampleAction, and runs the actual blockchain node.
This project consists of the ActionLoader
class, used for loading actions, and the ActionBase
class, which serves as the base class for action implementations. Additionally, it includes various action implementations. Both of these classes can be used as-is without modification.
AddNumber
is an example of an actual action implementation that inherits from ActionBase
and includes following several essential components.
ActionType
attribute
[ActionType("AddNumber")]
An action identifier. An exception will be thrown if the field is missing.
- Inherit
ActionBase
parent class
public class AddNumber : ActionBase
Only ActionBase
-typed classes can be read from ActionLoader
, all actions must inherit ActionBase
class to use ActionLoader
as-is without modification.
PlainValueInternal
property
protected override IValue PlainValueInternal { get; }
Actions are serialized as IValue
-typed value inside Libplanet. This property defines serialization of the action that inherits ActionBase
classes.
LoadPlainValueInternal
method
protected override void LoadPlainValueInternal(IValue plainValue)
{
...
}
Defines deserialization of the action that inherits ActionBase
classes.
Execute
method
public override IWorld Execute(IActionContext context)
{
...
}
Implements actual action logic. For implementation detail, check IAction
document.
builder.Services.AddLibplanetNode(builder.Configuration);
Injects Libplanet related services.
RPC related protobufs are defined in ./Protos. Basically port number 5260 is opened for RPC communication.