Skip to content

The way to change the state of Nine Chronicles’ blockchain is to issue a transaction.

Transaction

A transaction in Libplanet contains an action that changes the state on the blockchain network, and Nine Chronicles issues one transaction with one action.[1]

Action

Actions contain the arguments needed to change the state and the method that actually changes the state, and there are many types of actions defined in Nine Chronicles.[2]

Mead

Mead is the basic currency needed to execute actions, and the way to get it is through the Pledge system. For more information, check out this article.

Get Balance:

cs
public FungibleAssetValue? GetMead(IWorld world, Address address)
{
    CurrencyAccount currencyAccount = world.GetCurrencyAccount(currency);
    return currencyAccount.GetBalance(address, currency);
    // or
    Currency currency = Currencies.Mead;
    return world.GetBalance(address, currency);
}

Action Point

Some actions require a resource called Action Point to perform. These points are maxed out at 120 [3] when you create your avatar, and can then be earned through [Patrol Rewards] (https://docs.nine-chronicles.com/introduction/intro/game-contents/patrol-rewards), AP Potion [4], and more.

Get State:

cs
public int? GetActionPoint(IWorld world, Address address)
{
    IAccount account = world.GetAccount(Addresses.ActionPoint);
    if (account is null)
    {
        return null;
    }

    IValue state = account.GetState(address);
    return state switch
    {
        Bencodex.Types.Integer i => i,
        _ => null,
    };
}

  1. In the Nekoyume.Blockchain.Policy.BlockPolicySource.ValidateNextBlockTxRaw method of Lib9c, we are checking that a transaction contains only one action. ↩︎

  2. Check out the actions defined in the Nekoyume.Action namespace in Lib9c. ↩︎

  3. The maximum number of action points is defined as 120 in Nekoyume.Action.DailyReward.ActionPointMax. ↩︎

  4. An item that fills your AP to the maximum. ↩︎