ark net
Major ARK-NET update!!!

ARK.NET是.NET平台的ARK生態系統庫。它實現了所有最相關的方舟功能,以幫助您開發在方舟平台上構建的高效.NET應用程序。它還提供了低水平的方舟訪問權限,因此您可以在其頂部輕鬆地構建應用程序。
包裝支持:
install-package ark.net在nuget網站上獲取更多信息。
為了自己編譯,您可以git克隆,打開項目並點擊Visual Studio上的編譯按鈕。在命令提示中:
git clone https://github.com/ArkEcosystem/ark-net
cd ark-net
所有ARK節點服務響應都有對象表示。您可以在服務文件夾下使用服務類。對於單個項目的列表或對象,響應是可以的。每種方法都有相應的異步方法。
最好讓代碼進行講話。有關更多示例,請查看ARK.NET測試,其中所有測試均已編寫,您可以看到API使用情況。某些代碼片段在下面。
需要開始第一個呼叫,因此庫中的所有設置都可以在採取行動之前初始化。可以同時使用多個arknetapi實例(在同一應用程序中Devnet&Mainnet)
private ArkNetApi _arkNetApi ;
public ArkNetApi ArkNetApi
{
get { return _arkNetApi ?? ( _arkNetApi = new ArkNetApi ( ) ) ; }
}
await ArkNetApi . Start ( NetworkType . MainNet ) ; //Other type is DevNet
//or
await ArkNetApi . Start ( specificPeerIp , specificPeerPort ) ;
//or (Multiple addresses)
await ArkNetApi . Start ( listArkPeerAddresses ) ; //Existing account
var accCtnrl = new AccountController ( ArkNetApi , "top secret pass" ) ;
//Send ARK
var result = accCtnrl . SendArk ( 100 , "AUgTuukcKeE4XFdzaK6rEHMD5FLmVBSmHk" , "Akr.Net test trans from Account" ) ;
//Vote 4 Delegate
var result = accCtnrl . VoteForDelegate ( delegateName ) ;
//Un-Vote Delegate
var result = accCtnrl . UnVoteDelegate ( delegateName ) ;
//Create and send transaction. Transaction can be saved offine (.ToJson()) and sent later.
var transaction = accCtnrl . CreateTransaction ( 100 , "AUgTuukcKeE4XFdzaK6rEHMD5FLmVBSmHk" , "Akr.Net test trans from Account" ) ;
var result = accCtnrl . SendTransaction ( transaction ) ;
//Get Account
var account = accCtnrl . GetArkAccount ( ) ;
//New Account
new AccountController ( ArkNetApi , ArkNetApi . AccountService . GeneratePassphrase ( ) ) ;有關可用API電話的完整列表,請查看ARK.NET測試項目
//PeerService
var peers = ArkNetApi . PeerService . GetAll ( ) ;
var peersOK = peers . Where ( x => x . Status . Equals ( "OK" ) ) ;
//TransactionService
var trans = ArkNetApi . TransactionService . GetAll ( ) ;
//BlockService
var blocks = ArkNetApi . BlockService . GetAll ( ) ;
//AccountService - Generate passphrase
var result = ArkNetApi . AccountService . GeneratePassphrase ( ) ;
//DelegateService
var delegates = ArkNetApi . DelegateService . GetAll ( ) ;
//LoaderService
var autoConfigParams = ArkNetApi . LoaderService . GetAutoConfigureParameters ( ) ;
.. .層用於核心方舟區塊鏈通信(交易,加密...)。它由從服務和帳戶層調用的API庫包裹。
//Create & send transaction
TransactionApi tx = ArkNetApi . TransactionApi . CreateTransaction ( recepient , amount , description , passphrase ) ;
Peer peer = ArkNetApi . NetworkApi . GetRandomPeer ( ) ;
var result = peer . PostTransaction ( tx ) ;
//Connect to a specific peer to perform requests
var peerApi = new PeerApi ( ArkNetApi , ipAddress , Port )
await peerApi . MakeRequest ( ArkStaticStrings . ArkHttpMethods . GET , ArkStaticStrings . ArkApiPaths . Loader . GET_STATUS ) ;
//Force specific peer. All API calls will flow through this peer. Set back to null to resume decentralized use. Monitoring a specific peer is a use case for this functionality.
ArkNetApi . NetworkApi . ForcedPeer = ArkNetApi . PeerService . GetPeer ( ip , port ) ;
//or
ArkNetApi . NetworkApi . ForcedPeer = new PeerApi ( ArkNetApi , ipAddress , Port ) ;
// Switch network (Can also create new ArkNetApi instance as alternative solution)
await ArkNetApi . SwitchNetwork ( NetworkType . DevNet )
//New network
_arkNetApiDevNet = new ArkNetApi ( ) ;
await _arkNetApiDevNet . Start ( NetworkType . DevNet ) ; 任何記錄框架都可以用來捕獲arnknet內的日誌。它由庫的用戶來實現iarklogger並將其傳遞給arknetapi.start()。以下是使用log4net實現的示例。
public class Log4netAdapter : IArkLogger
{
private readonly ILog _log4NetLog ;
public Log4netAdapter ( ILog log4NetLog )
{
_log4NetLog = log4NetLog ;
}
public void Log ( ArkLogEntry entry )
{
if ( entry . LogLevel == ArkLogLevel . Debug )
_log4NetLog . Debug ( entry . Message , entry . Exception ) ;
else if ( entry . LogLevel == ArkLogLevel . Info )
_log4NetLog . Info ( entry . Message , entry . Exception ) ;
else if ( entry . LogLevel == ArkLogLevel . Warn )
_log4NetLog . Warn ( entry . Message , entry . Exception ) ;
else if ( entry . LogLevel == ArkLogLevel . Error )
_log4NetLog . Error ( entry . Message , entry . Exception ) ;
else
_log4NetLog . Fatal ( entry . Message , entry . Exception ) ;
}
}
ILog log = LogManager . GetLogger ( typeof ( LoggingTests ) ) ;
await ArkNetApi . Start ( NetworkType . MainNet , new Log4netAdapter ( log ) ; 請使用GitHub問題進行問題或反饋。有關機密要求或特定要求,請通過我們的公共渠道與我們聯繫。
如果您在此軟件包中發現了安全漏洞,請發送電子郵件至[email protected]。所有安全漏洞將立即解決。
©Arkecosystem