Code Monkey home page Code Monkey logo

sw4-account-creator's Introduction

SW4 Account Creator

Overview

sw4-account-creator is a streamlined, single-page web server designed specifically for the StatelessNET chain. This project is part of the event Stake Wars IV: Attack of the Transactions. Built on the robust actix-web framework, it offers a user-friendly interface for creating new accounts on the StatelessNET chain, which is a feature-preview network operational during the event.

Features

  • Account Creation: Users can easily create a new account by providing their desired account ID and public Ed25519 key.
  • Transaction Handling: The server automates the process of sending transactions on behalf of a top-level account (configured in the settings) to establish the new account.
  • Funding Accounts: Newly created accounts are automatically funded with a predefined amount of NEAR tokens, ensuring immediate usability.

Current status

  • Single-page template with a form for account creation
  • Connect HTMX(https://htmx.org/) to the page
  • Set up a form submission and replace the form with the result (partial template)
  • Parse account_id and public_key from the form
  • Response with a meaningul error message if the form is not valid
    • Validate account is not taken (as simple as possible)
    • Public key is a valid Ed25519 key
  • Retry in case of nonce conflict
  • (Optional) Protect from spamming
  • Craft a transaction to create the account
  • Sign the transaction with the key of the top-level account
    • Top-level account and its key are configured in the settings
  • Feature contract-helper that provides essential API for the Wallets (similar to the contract-helper)
    • GET account/keys/{public_key} Finds all the accounts with the given public key
    • GET account/{account_id}/txns Finds all the transactions for the given account
    • GET account/{account_id}/likelyTokensFromBlock Finds all the assets most likely to be [fungible] tokens for the given account from the given block
    • GET account/{account_id}/likeleNFTsFromBlock Finds all the assets most likely to be NFTs for the given account from the given block
    • POST account/create Creates a new account with the given account_id and public_key

Configuration

The server is configured using environment variables. The following variables are required:

  • NEAR_RPC_URL - URL of the NEAR RPC endpoint
  • BASE_SIGNER_ACCOUNT_ID - Account ID of the top-level account that will sign transactions
  • BASE_SIGNER_SECRET_KEY - Private key of the top-level account
  • FUNDING_AMOUNT - Amount of NEAR tokens to fund new accounts with (default 100NEAR)
  • SERVER_PORT - Port to listen on (default 10000)
  • [contract-helper feature] DATABASE_URL - PostgreSQL connection string to the ExplorerDB

Getting Started

It is expected the server will be running in Docker container. The following commands will build and run the server in a container:

docker build -t sw4-account-creator .

Put the configuration in a file called .env in the root of the project. The file should look like this:

NEAR_RPC_URL=http://localhost:3030
BASE_SIGNER_ACCOUNT_ID=near
BASE_SIGNER_SECRET_KEY=ed25519:...
FUNDING_AMOUNT=100000000000000000000000000
SERVER_PORT=10000
RUST_LOG=info

Then run the server with:

docker run --env-file .env -p 10000:10000 sw4-account-creator

Usage

./targer/release run --server-port 8080 --near-rpc-url http://localhost:3030 --base-signer-account-id near --base-signer-secret-key "ed25519:..." --funding-amount 100000000000000000000000000

sw4-account-creator's People

Contributors

khorolets avatar marcelo-gonzalez avatar heroes-bounty[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.