MicroCoin Rider is an API server for the MicroCoin ecosystem. It acts as the interface between MicroCoin network and applications that want to access the MicroCoin network. It allows you to submit transactions to the network, check the status of accounts, subscribe to transactions, etc. Rider provides a RESTful API to allow client applications to interact with the MicroCoin network. You can communicate with Rider using cURL or just your web browser. However, if you’re building a client application, you’ll likely want to use a MicroCoin SDK in the language of your client";
Before you start developing useful to download the MicroCoin wallet. You can download the latest version from here MicroCoin Wallet
MicroCoin Rider is a simple REST API. You can call using any language what you prefer. At this time we are offering PHP and Javascript SDKs, but you can generate your own using the swagger codegen project.
We have two networks. The Mainnet, where the production coin runs and the Testnet where you can develop. The primary Mainnet endpoint: https://rider.microcoin.hu. The primary Testnet endpoint: https://testnet.rider.microcoin.hu.
In other cryptocoins you can generate an "address" to receive coins. In MicroCoin that's not possible, address's are like accounts and accounts are generated by the blockchain. So, the main difference, is that if you don't have a MicroCoin account (mined by yourself or received from another account's owner) you cannot have receive MicroCoins.
An account can only be operated by a private key. Account's owners can change the account's key to a new one. You can generate a Private/Public key pair. You send the PUBLIC KEY (Note: private key must always be kept private and only for you!) to the owner of an account. The account's owner changes the key of an account to your new public key. After this, the owner of the account will be you, and the old owner will not have access to operate with this account because he doesn't know the private key. For testing and developing you can use the Testnet. On the Testnet you can easily mining accounts.
- PHP 5.5 or later
- Network connection
First you need a MicroCoin Client PHP SDK.
You can install with composer
composer require microcoin/microcoin
You can download it from here, or clone from our Github repository.
git clone https://github.com/MicroCoinHU/MicroCoin-PHP-SDK.git
# install PHP dependencies
composer install
# or install without dev dependencies
composer install --no-dev
# run example
php example.php
MicroCoin works with ECDSA signatures, so you need to work with ECDSA keys and signatures.
You can use your favorite ECDSA package, or use simplito/elliptic-php
. We are using simplito/elliptic-php
in our demos.
You can find a detailed documentation on the official github page: https://github.com/simplito/elliptic-php
If you have no keys, you must generate a new key, then store it in a secure place. Please note: if you lose your key, you lose your accounts and your coins
use Elliptic\EC;
$ec = new EC('secp256k1');
$myKey = $ec->genKeyPair();
If you have a key, you can import it from a hexadecimal string.
use Elliptic\EC;
$ec = new EC('secp256k1');
$myKey = $ec->keyFromPrivate("PRIVATE KEY IN HEX");
If you have accounts you can list there. First time you have no accounts, so you need get one. Every account belongs to a public key. One public key can be used for multiple accounts.
$api = new \MicroCoin\Api\AccountApi();
// You must convert the ECPoint to a MicroCoin SimpleKey
$key = new \MicroCoin\Model\SimpleKey();
$key->setCurveType("secp256k1");
$key->setX($myKey->getPublic()->getX()->toString(16));
$key->setY($myKey->getPublic()->getY()->toString(16));
print_r($api->myAccounts($key));
You can purchase accounts, but you need to know which accounts are for sale.
$api = new \MicroCoin\Api\AccountApi();
print_r($api->getOffers());
You can purchase any account for sale, if you have enough coins.
$api = new \MicroCoin\Api\AccountApi();
// First convert your public key
$key = new \MicroCoin\Model\SimpleKey([
"curve_type" => "secp256k1",
"x" => $myKey->getPublic()->getX()->toString(16),
"y" => $myKey->getPublic()->getY()->toString(16)
]);
$purchaseAccountRequest = new \MicroCoin\Model\PurchaseAccountRequest();
// Account to purchase
$purchaseAccountRequest->setAccountNumber('0-10');
// Optional fee
$purchaseAccountRequest->setFee(0);
// This account will pay the price and the fee
$purchaseAccountRequest->setFounderAccount('1-22');
// The new owner
$purchaseAccountRequest->setNewKey($key);
// preapare transaction
$transaction = $api->startPurchaseAccount($purchaseAccountRequest);
// Sign transaction
$sign = $myKey->sign($transaction->getHash());
// Fill signature
$transaction->setSignature(new \MicroCoin\Model\Signature(["r"=>$sign->r->toString(16), "s"=>$sign->r->toString(16)]));
// Commit transaction
$result = $api->commitPurchaseAccount($transaction);
// You are done
print_r($result);
If you have enough balance, you can send coins from your accounts to any valid account.
$api = new \MicroCoin\Api\TransactionApi();
$sendCoinRequest = new \MicroCoin\Model\TransactionRequest();
// Source account
$sendCoinRequest->setSender('0-10');
// Destination account
$sendCoinRequest->setTarget('1-22');
// Amount to send
$sendCoinRequest->setAmount(0.0001);
// Optinal fee
$sendCoinRequest->setFee(0);
// Optional payload
$sendCoinRequest->setPayload("Hello MicroCoin");
// Prepare a new transaction
$transaction = $api->startTransaction($sendCoinRequest);
// Sign transaction with your private key (private key what belongs to the sender account)
$sign = $myKey->sign($transaction->getHash());
// Fill signature
$transaction->setSignature( new \MicroCoin\Model\Signature(["r"=>$sign->r->toString(16), "s"=>$sign->r->toString(16)]) );
// Commit transaction
$result = $api->commitTransaction($transaction);
// Coins sent
print_r($result);
If you want change your account owner, you can do it with change the assigned public key.
$changeKeyRequest->setAccountNumber('0-10');
// Key of the new owner
$changeKeyRequest->setNewOwnerPublicKey(new \MicroCoin\Model\SimpleKey([
"curve_type" => "secp256k1",
"x" => $newKey->getPublic()->getX()->toString(16),
"y" => $newKey->getPublic()->getY()->toString(16)
]));
$changeKeyRequest->setFee(0);
// Prepare transaction
$transaction = $api->startChangeKey($changeKeyRequest);
// Fill signature
$transaction->setSignature( new \MicroCoin\Model\Signature(["r"=>$sign->r->toString(16), "s"=>$sign->r->toString(16)]) );
// Commit transaction
$result = $api->commitPurchaseAccount($transaction);
// You are done
print_r($result);
You can fetch the transaction history of any account
$api = new \MicroCoin\Api\AccountApi();
print_r($api.getTransactions("0-10"));