0.0.7 • Published 1 year ago

smartr v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago


GitHub license npm npm Github Stars

Solidity State Machine with Git

This repository demonstrates how to create a simple Solidity state machine using Git for state management, smart contract storage, and ledger tracking in JavaScript. The example provides a basic setup for implementing a state machine using a Solidity smart contract, where the contract's state and transaction ledger are stored as JSON files and managed using Git commits.

Please note: This example is for educational purposes only and is not suitable for use in production environments. For real-world applications, consider using a more robust solution.

Design

The main exe is smartr.js this will operate on one or more data directories.

Each data directory contains

  • ledger.json
  • state.json
  • contract.sol

Future versions will allow and quickjs contracts

Features

  • Solidity smart contract for a simple state machine
  • State and ledger stored in JSON files
  • Git for versioning and tracking state and ledger changes

Prerequisites

  • Node.js (v12.x or higher recommended)
  • NPM (v6.x or higher recommended)
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/solidity-state-machine-git.git
    cd solidity-state-machine-git
  2. Install the required packages:

    npm install

Usage

  1. Create a Solidity smart contract (e.g., ./data/Example.sol) with the desired state machine logic.

    Example:

    pragma solidity ^0.8.0;
    
    contract Example {
        uint256 public value;
    
        function setValue(uint256 newValue) public {
            value = newValue;
        }
    }
  2. Modify ./fastr.js` to reference the correct contract file and include any additional functions needed for your specific use case.

  3. Initialize the Git repository and create the initial state and ledger files:

    git init
    mdkir data
    echo '{"value": 0}' > data/state.json
    echo '[]' > data/ledger.json
    git add data/state.json data/ledger.json
    git commit -m "Initial state and ledger"
  4. Run the ./fastr.js` file to execute a function from the smart contract and update the state and ledger:

    ./smart.js [params]

Contributing

Contributions are welcome! Feel free to submit issues and pull requests for any bugs, improvements, or new features.

License

  • MIT
0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago