Flutter के लिए Archethic dart लाइब्रेरी नोड और ब्राउज़र के लिए। यह लाइब्रेरी Archethic लेनदेन बनाने और नेटवर्क पर भेजने का आसान तरीका प्रदान करने का उद्देश्य रखती है
सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
archethic_lib_dart पैकेज एक Dart लाइब्रेरी है जो Flutter एप्लिकेशन के लिए डिज़ाइन की गई है, जो नोड.जी और ब्राउज़र वातावरण में Archethic ब्लॉकचेन लेनदेन बनाने और भेजने की अनुमति देती है। यह लेनदेन उत्पादन, क्रिप्टोग्राफिक ऑपरेशन और नेटवर्क संचार के लिए उपकरण प्रदान करके Archethic नेटवर्क के साथ इंटरैक्शन को सरल बनाती है। Web3 और ब्लॉकचेन उपयोग केस के लिए बनाई गई, यह सुरक्षित, डिसेंट्रलाइज्ड एप्लिकेशन विकास का समर्थन करती है। लाइब्रेरी खुला स्रोत है और Archethic.net द्वारा बनाए रखी जाती है।
उपयोग
ब्लॉकचेन लेनदेन बनाना
Archethic नेटवर्क में डेटा भेजना
डेसेंट्रलाइज्ड ऐप्स (dApps) का निर्माण
Archethic के ब्लॉकचेन के साथ एकीकरण
सुरक्षित पीयर-टू-पीयर संदेश सक्षम करना
डिजिटल पहचान प्रबंधन का समर्थन करना
मुख्य विशेषताएँ
लेनदेन निर्माण सहायता
गोपनीय साइनिंग समर्थन
क्रॉस-प्लेटफॉर्म संगतता (Node और ब्राउज़र)
Flutter के साथ आसान एकीकरण
ओपन-सोर्स और सक्रिय रूप से बनाए रखा जा रहा है
हल्का और मॉड्यूलर डिज़ाइन
इनके लिए उपयुक्त
Flutter विकासकर्मी dApps बना रहे हैं
वेब3 एप्लिकेशन निर्माता
ब्लॉकचेन प्रेमी
Archethic नेटवर्क एकीकरणकर्ता
क्रिप्टो-फोकस्ड मोबाइल और वेब ऐप्स
सुरक्षित लेनदेन प्रबंधन की आवश्यकता वाले विकासकर्ता
विचार योग्य बातें
Archethic ब्लॉकचेन अवधारणाओं की समझ की आवश्यकता होती है
उपलब्ध दस्तावेज़ सीमित हैं
बाहरी Archethic नेटवर्क नोड्स पर निर्भर करता है
निम्न स्तर के ब्लॉकचेन प्रोटोकॉल विकास के लिए उपयुक्त नहीं
उत्पादन में अतिरिक्त त्रुटि संभाल की आवश्यकता हो सकती है
प्लेटफॉर्म-विशिष्ट व्यवहार में नोड और ब्राउज़र के बीच भिन्नता हो सकती है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Archethic's lib_dart
Archethic dart library for Flutter
Usage
This library aims to provide a easy way to create Archethic transaction and to send them over the network.
It supports the Archethic Cryptography rules which are:
Algorithm identification: keys are prepared by metadata bytes to indicate the curve used and the origin of the generation, and hashes are prepended by a byte to indicate the hash algorithm used.
Those information help during the verification
To be able to retrieve previous public key, the Archethic network designs the key derivation through a seed (passphrase) and an index(number of
previous public keys/transactions).
The procedure is described as follows:
The seed generates a master key and an entropy used in the child keys generation.
/ (256 bytes) Next private key
(256 bytes) Master key --> HMAC-512
/ Key: Master entropy,
seed --> HMAC-512Data: Master key + index)
\
(256 bytes) Master entropy
API
Cryptographic functions
deriveKeyPair(seed, index, curve, isSeedHexa)
It creates a new keypair into hexadecimal format
seed is hexadecimal encoding or Uint8Array representing the transaction chain seed to be able to derive and generate the keys
index is the number of transactions in the chain, to generate the actual and the next public key (see below the cryptography section)
curve is the elliptic curve to use for the key generation (can be "ed25519", "P256", "secp256k1") - default to: "ed25519"
isSeedHexa is a parameter used to specify whether the information is in hexadecimal format or not (and thus avoid conversion issues).
originId is the origin of the public key (can be 0 for "on chain wallet", 1 for "software" or 2 for "tpm") - default to: 1
new Transaction(type) creates a new instance of the transaction
type is the string defining the type of transaction to generate ("keychain", "keychain_access", "transfer", "hosting", "code_proposal", "code_approval", "token", "contract", "data")
The transaction instance contains the following methods:
setCode(code) (before transaction version 4)
Add the code in the data.code section of the transaction
code is a string defining the smart contract
This method is available for transaction version <= 3
setContract(contract) (after transaction version 4)
Add the contract in the data.contract section of the transaction
contract is an object with following keys:
bytecodeUint8List of the compiled wasm code compressed using zip
manifest the manifest of the contrat containing actions and functions spec
setContent(content)
Add the content in the data.content section of the transaction
content is a string defining the smart contract
addOwnership(secret, authorizedKeys)
Add an ownership in the data.ownerships section of the transaction with a secret and its related authorized public keys to be able to decrypt it.
This aims to prove the ownership or the delegatation of some secret to a given list of public keys.
secret is the hexadecimal encoding or Uint8Array representing the encrypted secret
authorizedKeys is a list of object represented by
publicKey is the hexadecimal encoding or Uint8Array representing the public key
encryptedSecretKey is the hexadecimal encoding or Uint8Array representing the secret key encrypted with the public key (see ecEncrypt)
addUCOTransfer(to, amount)
Add a UCO transfer to the data.ledger.uco.transfers section of the transaction
to is hexadecimal encoding or Uint8List representing the transaction address (recipient) to receive the funds
Sign the transaction with an origin device private key
privateKey is hexadecimal encoding or Uint8List representing the private key to generate the origin signature to able to perform the ProofOfWork and authorize the transaction
Query a node to add a new origin public to be authorized to sign transaction with the corresponding private key (see OriginSign).
Calls the 'add_origin_key' JSON-RPC 2.0 method
originPublicKey is the public key to be added.
certificate is the certificate that prove the public key is allowed to be added.
Fetch the OracleChain data
return a value of Oracle Uco_Price in {OracleUcoPrice} from a timestamp
If timestamp = 0 or not precised, the last price is returned
timestamp: UNIX timestamp (optional)
import'package:archethic_lib_dart/archethic_lib_dart.dart';
final oracleData =
awaitOracleService('https://testnet.archethic.net').getOracleData(timestamp);
final eurConversionRate = oracleUcoPrice.uco?.eur;
final usdConversionRate = oracleUcoPrice.uco?.usd;
getTransactionFee(tx)
Query a node to fetch the tx fee for a given transaction
Calls the 'estimate_transaction_fee' JSON-RPC 2.0 method
Once retrieved the keychain provide the following methods:
buildTransaction(tx, serviceName, index, suffix)
Generate address, previousPublicKey, previousSignature of the transaction and
serialize it using a custom binary protocol, based on the derivation path, curve and hash algo of the service given in param.
tx is an instance of Transaction
serviceName is the service name to use for getting the derivation path, the curve and the hash algo
index is the number of transactions in the chain, to generate the actual and the next public key (see the cryptography section)
suffix: Additional information to add to a service derivation path (default to empty)
Return is the signed Transaction. Notice that the function also sign the Transaction given in param, so getting the return is not mandatory
Use ec encryption on the seed for the list of authorizedPublicKeys
service: Service name to identify the derivation path to use
authorizedPublicKeys: List of public keys to encrypt the service seed
final keychain = Keychain(seed: hexToUint8List(generateRandomSeed())).copyWithService('uco', "m/650'/uco");
final storageNoncePublicKey = awaitApiService('https://testnet.archethic.net').getStorageNoncePublicKey();
final resultECEncryptServiceSeed = keychain.ecEncryptServiceSeed('uco', [storageNoncePublicKey]);
final secret = uint8ListToHex(resultECEncryptServiceSeed.secret);
final authorizedPublicKeys = resultECEncryptServiceSeed.authorizedPublicKeys;
// secret and authorizedPublicKeys can be used to create an ownershipfinal tx = Transaction(
type: 'contract',
data: Transaction.initData(),
).addOwnership(secret, authorizedPublicKeys);
toDID()
Return a Decentralized Identity document from the keychain. (This is used in the transaction's content of the keychain tx)
Keychain keychain = awaitApiService('https://testnet.archethic.net').getKeychain(accessKeychainSeed);
finalMap<String, dynamic> did = keychain.toDID();
log(did)
{
"@context": [
"https://www.w3.org/ns/did/v1"
],
"id": "did:archethic:keychain_address",
"authentification": servicesMaterials, //list of public keys of the services"verificationMethod": servicesMaterials //list of public keys of the services
}