AlgorandARC4Parser 1.0.2

This package has a SemVer 2.0.0 package version: 1.0.2+20250722T021900.
There is a newer version of this package available.
See the version list below for details.
dotnet add package AlgorandARC4Parser --version 1.0.2
                    
NuGet\Install-Package AlgorandARC4Parser -Version 1.0.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="AlgorandARC4Parser" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AlgorandARC4Parser" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="AlgorandARC4Parser" />
                    
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 AlgorandARC4Parser --version 1.0.2
                    
#r "nuget: AlgorandARC4Parser, 1.0.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 AlgorandARC4Parser@1.0.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=AlgorandARC4Parser&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=AlgorandARC4Parser&version=1.0.2
                    
Install as a Cake Tool

Algorand ARC4 Parser

The Algorand ARC4 Parser is a .NET library designed to parse and convert ARC4-encoded data structures. It provides a robust and extensible framework for working with on-chain data representations, enabling seamless decoding and conversion of complex data types.

Features

  • ARC4 Parsing: Decode ARC4-encoded data structures into strongly-typed C# objects.
  • Customizable Converters: Support for custom converters for specialized data types.
  • Extensive Type Support: Includes support for primitive types, arrays, tuples, and structs.
  • Annotations: Use [Arc4Property] attributes to map ARC4 fields to C# properties.
  • Test Coverage: Comprehensive test cases to ensure reliability and correctness.

Installation

To use this library, include the project in your .NET solution or add it as a dependency.

Usage

Parsing ARC4 Data

To parse ARC4 data, define your data model and annotate it with [Arc4Property] attributes.

You also need to create a JSON mapping file, example:

{
    "kind": "struct",
    "name": "Product",
    "fields": [
        { "name": "version", "type": { "kind": "primitive", "name": "uint", "size": 32 } },
        { "name": "seed", "type": { "kind": "primitive", "name": "string", "size": 22 } },
        { "name": "createdDate", "type": { "kind": "primitive", "name": "date", "size": 64 } },
        { "name": "price", "type": { "kind": "primitive", "name": "uint", "size": 64 } },
        { "name": "priceToken", "type": { "kind": "primitive", "name": "uint", "size": 64 } },
        { "name": "royalty", "type": { "kind": "primitive", "name": "uint", "size": 16 } },
        { "name": "seller", "type": { "kind": "primitive", "name": "address" } },
        { "name": "categoryId", "type": { "kind": "primitive", "name": "uint", "size": 64 } },
        { "name": "groupSeed", "type": { "kind": "primitive", "name": "string", "size": 22 } },
        { "name": "expirationDate", "type": { "kind": "primitive", "name": "date", "size": 64 } },
        { "name": "totalCodes", "type": { "kind": "primitive", "name": "uint", "size": 32 } },
        { "name": "orderCount", "type": { "kind": "primitive", "name": "uint", "size": 32 } },
        { "name": "codesBitmap", "type": { "kind": "primitive", "name": "uint", "size": 128 } },
        {
            "name": "codeManifest",
            "type": {
                "kind": "struct",
                "name": "CodeManifest",
                "fields": [
                    { "name": "manifestType", "type": { "kind": "primitive", "name": "uint", "size": 16 } },
                    { "name": "dataLocation", "type": { "kind": "primitive", "name": "string" } }
                ]
            }
        },
        { "name": "details", "type": { "kind": "primitive", "name": "bytes", "converter": "DetailsConverter" } }
    ]
}

C# class example:

using ARC4Parser;

public class Product
{
    [Arc4Property("version")]
    public uint Version { get; set; }

    [Arc4Property("seed")]
    public string Seed { get; set; } = "";

    [Arc4Property("price")]
    public ulong Price { get; set; }

    [Arc4Property("details", typeof(DetailsConverter))]
    public ProductDetails Details { get; set; } = new();
}

public class ProductDetails
{
    public string Name { get; set; } = "";
    public List<string> ImageUrls { get; set; } = new();
    public string Description { get; set; } = "";
}

Decoding Example

string json = File.ReadAllText("productStructNode.json");
StructTypeNode? structTypeNode = JsonConvert.DeserializeObject<StructTypeNode>(json);
string base64EncodedData = "AAAAAW1YamFmUW44UWtDQjUyaWlvd0JMY2cAAAAAaHQX5QAAAAAAHl1wAAAAAAAAAAAAZDn57aMrdoS8ODz5n0n0D9frQzN/x2eW4aODv2yHiiG7AAAAAAAAAA" +
                           "FtWGphZlFuOFFrQ0I1Mmlpb3dCTGNnAAAAAGiKo/AAAAAUAAAAAAAAAAAAAAAAAAAAAAAAAAAAlgDVAAEABAA5aHR0cHM6Ly9jZG4uYWxkZW1hcnQuY29tL2NvZGVzL2" +
                           "1YamFmUW44UWtDQjUyaWlvd0JMY2cudHh0ADlzyywqLlHISy1XKCjKTylNLnnUsFA/Kb8itRhE6qbrFeSlA4W8SoGqEsHqSlKBTKhiLpBATmZeKgA=";
byte[] buffer = Convert.FromBase64String(base64EncodedData);

Arc4Converter converter = new Arc4Converter();
Product product = converter.Process<Product>(structTypeNode, buffer);

Custom Converters

You can implement custom converters for specialized data types by inheriting from Arc4Converter.

Test Examples

The project includes a test project (ARC4ParserTests) with examples of how to use the library. Below is a sample test model:

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 0 8/3/2025
1.0.5 0 8/3/2025
1.0.4 5 8/3/2025
1.0.3 6 8/3/2025
1.0.2 11 7/22/2025
1.0.1 8 7/21/2025
1.0.0 435 7/21/2025

Vibecoded