archethic_lib_dart 패키지는 Flutter 애플리케이션을 위한 Dart 라이브러리로, Node.js 및 브라우저 환경에서 Archethic 블록체인 거래를 생성하고 전송할 수 있도록 해줍니다. 거래 생성, 암호화 작업, 네트워크 통신을 위한 도구를 제공함으로써 Archethic 네트워크와의 상호작용을 간소화합니다. Web3 및 블록체인 사용 사례를 고려하여 설계되었으며, 안전한 탈중앙화 애플리케이션 개발을 지원합니다. 이 라이브러리는 오픈소스이며 Archethic.net에서 유지보수됩니다.
사용 사례
블록체인 거래 생성
Archethic 네트워크로 데이터 전송
디센트럴라이즈드 앱(dApps) 만들기
Archethic 블록체인과의 통합
안전한 피어 투 피어 메시징 활성화
디지털 신원 관리 지원
주요 기능
트랜잭션 생성 유틸리티
암호 서명 지원
크로스플랫폼 호환성 (Node 및 브라우저)
Flutter와의 간편한 통합
오픈소스이며 지속적으로 유지 관리되고 있습니다
경량이고 모듈러한 디자인
적합한 대상
Flutter 개발자들이 dApps 구축 중
웹3 애플리케이션 창작자
블록체인 애호가
Archethic 네트워크 통합업체
암호화폐 중심의 모바일 및 웹 앱
안전한 거래 처리가 필요한 개발자
고려 사항
Archethic 블록체인 개념에 대한 이해가 필요합니다
사용 가능한 문서가 제한적입니다
외부 Archethic 네트워크 노드에 의존합니다
저수준 블록체인 프로토콜 개발에 적합하지 않습니다
생산 환경에서는 추가적인 오류 처리가 필요할 수 있습니다
플랫폼별 동작은 Node와 브라우저 간에 다를 수 있습니다
원본 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
}