Difference in concept: Epoch & storageLimit
In the Ethereum blockchain, only transactions on the main chain are valid, so it can be considered that the Ethereum blockchain ledger is a single chain, and each block from front to back has a number called block number. Conflux developed a new ledger structure: tree graph, which achieves high throughput and low latency.
In the block structure of the Tree Graph, it is a Tree if only the parent edge is looked at, and it is a Graph if both parent edges are looked at. It is this structure that allows Conflux networks to emit blocks simultaneously, that is, multiple blocks can be generated after a block. Therefore, there is no concept of block number in Conflux. However, in order to realize the complete order, Conflux starts from the genesis block by GHAST rule and selects the most barysubtree block from all its sub-blocks as pivot block. All pivot block chains to one block also form a chain defined as Pivot chain. If you just look at the pivot chain, which has the same structure as the ordinary blockchain, one Epoch is defined on the chain based on each pivot block. Therefore, you can understand the Epoch in Conflux as a concept corresponding to the block number. It’s just that there may be multiple blocks in each epoch in Conflux.
In the real world, banks pay fees to send money transactions, miners pay fees to send transactions in Bitcoin, and the same is true in Ethereum. Specifically, transactions on the Ethereum network are ultimately executed by EVM run by miners. Gas is used to measure the amount of work (i.e. hours of work) performed by a transaction. The transaction sender can specify the price he/she is willing to pay for each amount of work when sending a transaction, namely the gasPrice. So the final transaction fee is gas * gasPrice. The gas specified when sending a transaction is a limit value, that is, the maximum amount of time the sender is willing to pay GAS for a transaction. If the transaction requires more work than GAS, no more money will be paid and the transaction will not be executed.
In Dapp system, transaction execution requires miners not only to pay computing resources for calculation, but also to store the state of the contract, so storage resources need to be paid. When sending a transaction in the Conflux system, it is also necessary to pledge part of the cost for the state storage. Therefore, when sending a transaction in Conflux, there is one more parameter storageLimit than Ethereum, which is used to set the upper limit of the cost that is willing to pledge for a transaction storage. The cost of the mortgage is refunded after the contract frees up the storage used.
Development tool differences
Existing development tools for Conflux blockchain include Conflux Truffle and Conflux Studio, whose functions mainly correspond to Truffle and Remix, the most widely used development tools for Ethereum.
Conflux-Truffle Vs Truffle
Conflux-Truffle is a contract development tool for Conflux blockchain based on Truffle. See the Conflux-Truffle tutorial for details. It differs from Truffle in the following key points.
The name of the 1.
The project name | NPMJS package name | The name of the installed command line program |
---|---|---|
Conflux-Truffle |
conflux-truffle |
cfxtruffle |
Truffle |
truffle |
truffle |
2. Ganache
VS conflux-rust docker
Ganache is a tool for Truffle to quickly start the Ethereum private chain when developing smart contracts.
Conflux does not have a corresponding version of Ganache at the moment, but Conflux provides Conflux-Docker, which is also very convenient to use. Starting conflux-Docker will also start a private chain by default, allocate 10 initial accounts and allocate CFX, and automatically unlock these accounts.
The biggest difference between them is that Ganache provides a graphical interface to view the performance of the private chain and perform some simple functional interactions. Conflux will continue to improve user experience related functions.
3. subcommand
Sons command | Whether Truffle is supported | Conflux-truffle is supported or not |
---|---|---|
build | Has been out of date | N |
compile | Y | Y |
config | Y | Y |
console | Y | Y |
create | Y | Y |
debug | Y | Y |
deploy | Y | Y |
develop | Y | N |
exec | Y | Y |
help | Y | Y |
init | Y | Y |
install | Y | Y |
migrate | Y | Y |
networks | Y | Y |
obtain | Y | Y |
opcode | Y | Y |
publish | Y | Y |
run | Y | Y |
test | Y | Y |
unbox | Y | Y |
version | Y | Y |
watch | Y | Y |
Ctxtruffle does not support the cfxtruffle develop subcommand. The names and usage modes of other subcommands are the same as those of trffule. This feature will be added in a later release.
4. subcommand context
When running cfxTruffle console/exec/run, you can still interact with Conflux through THE RELATED API of JS-conflux-SDK, and inject the Conflux and Util modules of JS-Conflux-SDK, which can be used by CFX and cfxutil. As shown below.
# cfx
cfxtruffle(development)> await cfx.getBalance('0x148A9696F8DCf4d6cB01eC80F1047a3476bA5C56')
cfxtruffle(development)> await cfx.getNextNonce("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b")
# cfxutil
cfxtruffle(development)> letDrip = cfxutil. Unit. FromCFXToGDrip cfxtruffle (0.1) > (development)let randomKey = cfxutil.sign.randomPrivateKey()
Copy the code
5. Local signature remote deployment
In truffle, you can set HDWalletProvider to call the local wallet for signature. Cfxtruffle simply sets the privateKeys field in the network configuration, which is an array of privateKeys. When a transaction or deployment contract is sent, it automatically selects the corresponding private key from the list of changed privateKeys for signing. The sample is as follows
Truffle set
// truffle-config.js
testnet: {
provider: new HDWalletProvider("3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9580"."http://localhost:7545"),
network_id: "*".Note: privateKeys obtained from the portal need to be prefixed with 0x. PrivateKeys can also specify a single key. If a private key is configured, do not upload the code to the public code repository.
// privateKeys: ['your-private-key']
}
Copy the code
Conflux – Trffle Settings
// truffle-config.js
testnet: {
host: "test.confluxrpc.org".port: 80.network_id: "*".Note: privateKeys obtained from the portal need to be prefixed with 0x. PrivateKeys can also specify a single key. If a private key is configured, do not upload the code to the public code repository.
// privateKeys: ['your-private-key']
privateKeys: ['0x3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9583'.'0x4f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9581']}Copy the code
6. Parameters for calling RPC
As shown above, the conflux consensus mode is different from Ethereum, and the concepts of epoch and storageLimit are added, so it is often necessary to pass these parameters when interacting with Conflux through RPC. For specific differences, see the difference between RPC and SDK
Conflux Studio VS Remix
Conflux Studio is an integrated development environment that helps developers quickly develop Conflux smart contracts. Like Remix, it provides a graphical interface for developers to interact with contracts. Remix is a browser-based application, while Conflux Studio is a stand-alone executable with many differences in functionality and usage beyond the application type
function | Remix | Conflux Studio |
---|---|---|
Edit the contract | Y | Y |
Debug contract code | Y | N |
Contract error checking | Y | N |
Compile and deploy contracts | Y | Y operates on the Project page and is internally implemented as a callConflux-Truffle compile |
Display compilation and deployment results UI (including ABI and Bytecode) | Y | Y View the ABI of the contract compilation history in ABI Storage, |
Set the gaslimit | Y | N |
The constructor parameters are set when the contract is deployed | Y | N |
Load the contract instance based on the ABI and address | Y | N |
The Tuple mass participation | Y | N |
Support for compiler optimization | Y | N |
Support for automatic compilation of contracts | Y | N |
Contract Interaction UI | Y | Y Operates on the Contract page |
Command terminal | Y | Y |
Interact with the SDK in the command terminal | Web3 is injected into the command terminal | N |
Connect the nodes | Connect by setting the Node URL | Provides the Network TAB that allows you to create nodes locally, as well as testnet and Mainnet |
Create and manage nodes | Y | N |
The built-in execution environment JavaScript VM | Y | N |
Initial account Accounts | Automatic allocation, or import via Metamask | Manually import from keystore or create through IDE |
Support plug-in installation | Y | N |
Record transactions for replay (including transaction hashes, abi of transaction creation contract) | Y | N |
Unit Test | Y | N |
Import the project | Import projects from local and other sources, such as Github, Gist, IPfs, etc | The smart contract template is built in and operated on the Project page |
Account browser | N | Y Enter the account address in the address box of Explorer |