aelf 백서

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 41쪽 중 41쪽

ers generated through business actions on the contract. They are particularly useful for token transfers and other interactions where unique identification is crucial. In summary, Virtual Addresses in aelf blockchain enhance the flexibility and security of contract interactions by providing unique identifiers derived from the main contract Address. Overview User Address Contract Address Contract Virtual Address ## /learn/transactions On this page Overview Transactions play a critical role in modifying the state of the aelf blockchain through interactions with smart contracts. Here’s how transactions function: 1. Transaction Process: ​ Transactions are initiated by calling methods on smart contracts. They are either sent to a node through RPC (Remote Procedure Call) or received from the network. 2. Transaction Execution: ​ Upon broadcasting a transaction, if it meets validation criteria, it becomes eligible for inclusion in a block. Once included in a block and executed by the node, the transaction potentially alters the state of the involved contracts. In essence, transactions in aelf blockchain are fundamental actions that drive changes to the blockchain’s state, ensuring secure and efficient operation across the network. Smart Contract ​ In the aelf blockchain, smart contracts consist of two main components: 1. State Definitions: ​ Smart contracts define a set of variables that represent their state. These variables can store data such as account balances, token ownership, or any other relevant information. 2. Methods: ​ Smart contracts include a set of methods designed to interact with and modify these states. These methods are executed when triggered by transactions or external calls. They can update the state variables based on predefined rules and conditions. Smart contracts in aelf blockchain serve as self-executing contracts with predefined terms and conditions agreed upon by participating parties. They enable automated and trustless execution of agreements and transactions within the blockchain ecosystem. Action & View ​ In the aelf blockchain, smart contract methods are categorized into two types based on their functionality: actions and views . 1. Action Methods: ​ Definition : Action methods are designed to modify the state of a contract. Execution : When a transaction containing an action method is included in a block and successfully executed, it can change the internal state of the contract. Example ​ rpc Vote ( VoteInput ) returns ( google.protobuf.Empty ) { } Action methods are typically used for operations that alter data within the blockchain, such as updating balances, transferring tokens, or recording votes. 2. View Methods: ​ Definition : View methods retrieve data from the contract but do not modify its state under any circumstances. Execution : They are purely read-only operations. Example ​ rpc GetVotingResult ( GetVotingResultInput ) returns ( VotingResult ) { option ( aelf . is_view ) = true ; } View methods are annotated with option (aelf.is_view) = true; in their protocol buffer (proto) definitions. They are used for querying information stored in the contract, such as retrieving voting results, fetching account details, or checking contract status. These distinctions ensure that smart contracts in aelf blockchain can effectively manage state changes while maintaining secure and efficient data access. Transaction Instance ​ In the aelf blockchain, a Transaction is structured as follows: option csharp_namespace = "AElf.Types" ; message Transaction { Address from = 1 ; Address to = 2 ; int64 ref_block_number = 3 ; bytes ref_block_prefix = 4 ; string method_name = 5 ; bytes params = 6 ; bytes signature = 10000 ; } Working with Transactions in JS SDK ​ Use the getTransaction method to build a transaction object: import Aelf from 'aelf-sdk' ; var rawTxn = proto . getTransaction ( '65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9' , 'SomeMethod' , encodedParams ) ; This will create a transaction to the contract at address 65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9 and call SomeMethod with encoded parameters. Key Fields in Transactions ​ From : The sender's address. Currently derived from the signature. To : The contract address being called. MethodName : The name of the method in the smart contract. Params : The parameters to pass to the method. Signature : The signature of the transaction, which includes fields like from, to, method, parameters, reference block number, and prefix. Sign a transaction using the JS SDK: import Aelf from 'aelf-sdk' ; var txn = Aelf . wallet . signTransaction ( rawTxn , wallet . keyPair ) ; RefBlockNumber & RefBlockPrefix : Ensure the transaction is not expired. These two fields measure whether this transaction has expired. The transaction will be discarded if it is too old. Transaction Id : A unique identifier for the transaction, consisting of a cryptographic hash of the essential fields, excluding the signature. Note that the Transaction Id of transactions will be the same if the sender broadcasted several transactions with the same origin data, and then these transactions will be regarded as one transaction even though broadcasting several times. Verification ​ Before forwarding a transaction to other nodes, it is verified by the node. If the execution fails, the transaction is neither forwarded nor included in a new block. Validation providers include: BasicTransactionValidationProvider : Verifies transaction signature and size. TransactionExecutionValidationProvider : Pre-executes the transaction before forwarding or packaging it. TransactionMethodValidationProvider : Prevents view-only method transactions from being packaged into new blocks. Execution ​ In aelf, transactions are executed via the .NET reflection mechanism. Execution Plugins ​ FeeChargePreExecutionPlugin : Charges method fees from the sender. MethodCallingThresholdPreExecutionPlugin : Checks the calling threshold of specific contracts or methods. ResourceConsumptionPostExecutionPlugin : Charges resource tokens based on the resources consumed during execution. Transaction Result ​ The data structure for TransactionResult : message TransactionResourceInfo { repeated aelf . ScopedStatePath write_paths = 1 ; repeated aelf . ScopedStatePath read_paths = 2 ; ParallelType parallel_type = 3 ; aelf . Hash transaction_id = 4 ; aelf . Hash contract_hash = 5 ; bool is_nonparallel_contract_code = 6 ; } Smart Contract Action & View 1. Action Methods: 2. View Methods: Transaction Instance Verification Execution Transaction Result ## /learn/smart-contract 📄️ Architecture The aelf smart contract 📄️ Service gRPC and protobuf 📄️ Events Logging transaction events 📄️ Messages Calling smart contracts 🗃️ Restrictions Requirements and Restrictions ## /learn/acs-introduction 📄️ Contract Deployment ACS0 📄️ Transaction Fee ACS1 📄️ Parallel Execution ACS2 📄️ Contract Proposal ACS3 📄️ Consensus ACS4 📄️ Contract Threshold ACS5 📄️ Random Number ACS6 📄️ Contract CrossChain ACS7 📄️ Token Fee ACS8 📄️ Profit Dividend ACS9 📄️ Dividend Pool ACS10 📄️ Cross Chain Consensus ACS11 📄️ User Contract ACS12 ## /tools/faucet On this page aelf Faucet 1. Introduction ​ The aelf Testnet Faucet is a vital resource for developers working on the aelf blockchain. It provides free test tokens, particularly, ELF (native aelf token), Token type SEED token (for creation of new token), NFT type SEED token (for creation of new NFT collection), which are essential for deploying and testing smart contracts, running transactions, and exploring the functionalities of aelf without the risk of losing real assets. By using the faucet, developers can ensure their applications function correctly and efficiently before deploying them to the mainnet. 2. Using aelf Faucet ​ 2.1 Getting Testnet ELF Tokens ​ To deploy smart contracts or execute on-chain transactions on aelf, you'll require testnet ELF tokens. Get ELF Tokens Go to this url https://faucet-ui.aelf.dev . Enter your address and click Get Tokens . 2.2 Getting Testnet Token Type SEED Token ​ To acquire testnet Token type SEED for creating fungible or non-fungible tokens on aelf testnet. Get Token Type Seed Token Go to this url https://faucet-ui.aelf.dev . Click on the dropdown to select "Token Seed" . Enter your address and click Get Seed . 2.3 Getting Testnet NFT Type SEED Token ​ To acquire testnet NFT type SEED for creating fungible or non-fungible tokens on aelf testnet. Get NFT Type Seed Token Go to this url https://faucet-ui.aelf.dev . Click on the dropdown to select "NFT Seed" . Enter your address and click Get Seed . 1. Introduction 2. Using aelf Faucet 2.1 Getting Testnet ELF Tokens 2.2 Getting Testnet Token Type SEED Token 2.3 Getting Testnet NFT Type SEED Token ## /tools/oracle On this page 1. Overview ​ AetherLink is a decentralized oracle network that enables smart contracts to securely interact with real-world data and external APIs. It provides highly reliable and tamper-proof data inputs, which are essential for executing smart contracts that rely on off-chain information. AetherLink is built with security in mind, using decentralized node operators to prevent single points of failure, ensuring data integrity through multiple data sources, and offering verifiable randomness for enhanced transparency. Additionally, AetherLink is designed to be highly scalable, supporting a wide range of use cases from decentralized finance (DeFi) to gaming and beyond. AetherLink offers several key products that enhance the functionality of smart contracts: Datafeeds: AetherLink Datafeeds provide decentralized, real-time data from multiple sources, enabling smart contracts to access highly reliable and accurate off-chain information, such as asset prices, for secure decision-making in decentralized applications. VRF (Verifiable Random Function): AetherLink VRF delivers provably fair and verifiable random numbers, ensuring the randomness used in smart contracts is tamper-proof and transparent. This is particularly useful for gaming, lotteries, and any application that requires trusted randomness. Automation: AetherLink Automation allows developers to automate smart contract functions by triggering actions based on specific events or conditions. This reduces the need for manual intervention and ensures contracts execute efficiently and reliably when certain criteria are met. 2. Purpose ​ The go-to place for developers who want to learn how to build applications using AetherLink Contract. 3. What's Next? ​ You have now understood the basic functions of Oracle. Next, you can choose the appropriate Oracle product based on your scenario to make your DApp contract more secure and efficient. 1. Overview 2. Purpose 3. What's Next? ## /tools/chain-sdk 📄️ Javascript SDK Javascript SDK 📄️ C# SDK C# SDK 📄️ Go SDK Go SDK 📄️ JAVA SDK JAVA SDK 📄️ PHP SDK PHP SDK 📄️ Python SDK Python SDK ## /tools/aelf-cli 📄️ Introduction to CLI aelf's Command Line Interface 📄️ Commands aelf CLI Commands ## /quick-start/developers 📄️ Hello World Contract Simplest contract to get you started 📄️ Lottery Game Contract Moderately complex smart contract 📄️ DAO dApp Slightly more complex dApp 📄️ NFT dApp Very complex dApp 📄️ ToDo dApp Moderately difficult smart contract and dApp 📄️ Tic-Tac-Toe dApp Moderately difficult smart contract and dApp 📄️ Expense Tracker dApp Moderately difficult smart contract and dApp 📄️ Single Pool Staking dApp Moderately difficult DeFi smart contract and dApp 📄️ Allowance dApp Smart contracts explaining inter-contract calls 📄️ Dice Game dApp Moderately complex smart contract
프로젝트로 돌아가기