The difference between concepts: Epoch & storageLimit
In the Ethereum blockchain, only the 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 the block number. , conflux has developed a new ledger structure: tree graph, which achieves high throughput and low latency.
In the tree graph block structure, if you only look at the parent side, it is a Tree, and if the parent side refers to both sides, it is a Graph. It is this structure that allows the Conflux network to issue blocks concurrently, that is, multiple blocks can all be generated after a certain block. So there is no concept of block number in Conflux. However, in order to achieve total order, Conflux starts from the genesis block through the GHAST rule, and selects the heaviest subtree block as the pivot block among all its sub-blocks. All the pivot block chains to one block also form a chain defined as pivot chain. If Just look at the pivot chain, which is consistent with the ordinary blockchain structure. An Epoch is defined based on each pivot block on this chain. Therefore, you can understand the Epoch in conflux as a concept corresponding to the block number, except that the Epoch in conflux There may be multiple blocks in each epoch.
In the real world, sending a transfer transaction requires paying a fee to the bank, sending a transaction in Bitcoin requires paying a fee to the miner, and the same is true in Ethereum. Specifically, the transaction of the Ethereum network is finally executed by the EVM run by the miner. Gas is used to measure the workload of a transaction (which can be understood as the working hours). The sender of the transaction can specify the willingness to send the transaction. The price paid for each workload is gasPrice. So the final transaction fee is gas * gasPrice. The gas specified when sending a transaction is a limit value, that is, the sender is willing to pay so much gas for a transaction. be executed.
In the Dapp system, transaction execution requires miners to perform calculations and pay for computing resources, but also requires miners to store the state of the contract, so it needs to pay for storage resources. When sending a transaction in the Conflux system, it is also necessary to mortgage a part of the fee for state storage. Therefore, when sending a transaction in Conflux, there is one more storageLimit parameter than Ethereum, which is used to set the upper limit of the fee that is willing to be mortgaged for a certain transaction. After the contract releases the used storage space, the staking fee will also be returned.
Development tool difference
Conflux block chain existing development tools are Conflux Truffle
and Conflux Studio
, and its main function corresponding to Ethernet Square, the most widely used development tools Truffle
and Remix
.
Conflux-Truffle Vs Truffle
Conflux-Truffle
as to Truffle
as the prototype for the transformation of service contracts conflux block development tool chain. For details, please refer to Conflux-Truffle
usage tutorial . The main differences between it and Truffle
are as follows.
1. Name
project name | npmjs package name | The name of the command line program after installation |
---|---|---|
Conflux-Truffle | conflux-truffle | cfxtruffle |
Truffle | truffle | truffle |
2. Ganache
VS conflux-rust docker
Ganache
is a tool officially provided by Truffle to facilitate the quick start of the Ethereum private chain when developing smart contracts.
conflux Buyer No Ganache
corresponding version, but conflux provides conflux-docker
, is also very easy to use, start conflux-docker
default will start a private chain, the initial allocation of 10 accounts and assign cfx, and will automatically unlock these accounts.
The biggest difference between them is that Ganache
provides a graphical interface to view the operation of the private chain and do some simple functional interactions. conflux will improve user experience related functions in the future.
3. subcommand
subcommand | Does Truffle support | Does Conflux-Truffle support |
---|---|---|
build | obsolete | 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 subcommand cfxtruffle develop
, other subcommand names and usage are the same as trffule
; this function will be added in subsequent versions.
4. subcommand context
When running cfxtruffle console/exec/run
time, still can js-sdk
related api
and conflux
interaction, but also injected js-conflux-sdk
of Conflux
and Util
module, you can cfx
and cfxutil
use. As follows
# cfx
cfxtruffle(development)> await cfx.getBalance('0x148A9696F8DCf4d6cB01eC80F1047a3476bA5C56')
cfxtruffle(development)> await cfx.getNextNonce("0xbbd9e9be525ab967e633bcdaeac8bd5723ed4d6b")
# cfxutil
cfxtruffle(development)> let drip = cfxutil.unit.fromCFXToGDrip(0.1)
cfxtruffle(development)> let randomKey = cfxutil.sign.randomPrivateKey()
5. Local signature remote deployment
truffle
, you can call the local wallet to sign HDWalletProvider
cfxtruffle
, you only need to set the privateKeys
field in the network configuration. This field is an array of private keys. When sending a transaction or deploying a contract, it will automatically select the corresponding privateKeys
the private key to sign. Examples are as follows
Truffle
settings
// truffle-config.js
testnet: {
provider: new HDWalletProvider("3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9580", "http://localhost:7545"),
network_id: "*",
// 注意:从 portal 获取的私钥需要添加 0x 前缀,privateKeys 也可以指定单个 key,若配置了私钥,请注意不要将代码上传到公开代码仓储中。
// privateKeys: ['your-private-key']
}
Conflux-Trffle
settings
// truffle-config.js
testnet: {
host: "test.confluxrpc.org",
port: 80,
network_id: "*",
// 注意:从 portal 获取的私钥需要添加 0x 前缀,privateKeys 也可以指定单个 key,若配置了私钥,请注意不要将代码上传到公开代码仓储中。
// privateKeys: ['your-private-key']
privateKeys: ['0x3f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9583','0x4f841bf589fdf83a521e55d51afddc34fa65351161eead24f064855fc29c9581']
}
6. Parameters when calling rpc
As shown above, since the consensus method in conflux is different from that of Ethereum, and the concepts of epoch and storageLimit are added, these parameters are often required to be passed when interacting with conflux through rpc. For details, please refer to 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. Similar to Remix provides a graphical interface for developers to interact with contracts.
Remix is a browser-based application, while Conflux Studio is an independent executable program. In addition to the differences in program types, there are also many differences in its functions and usage methods.
Features | Remix | Conflux Studio |
---|---|---|
Edit 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 the internal implementation is to call Conflux-Truffle compile |
Display compilation and deployment result UI (including ABI and Bytecode) | Y | Y View the ABI of the contract compilation history in ABI Storage, |
set gaslimit | Y | N |
Set constructor parameters when deploying the contract | Y | N |
Load contract instance based on ABI and address | Y | N |
Tuple parameter | Y | N |
Support compilation optimization | Y | N |
Support automatic compilation of contracts | Y | N |
Contract interaction UI | Y | Y operates on the Contract page |
command terminal | Y | Y |
Interact with sdk in command terminal | web3 injected in command terminal | N |
connection node | Connect by setting the node url | Provides a Network tab, you can create nodes locally, you can also choose testnet and mainnet |
Create and manage nodes | Y | N |
Built-in execution environment JavaScript VM | Y | N |
Initial Account Accounts | Automatically assigned, or imported via metamask | Import manually based on keystore or create via IDE |
Support plug-in installation | Y | N |
Record the transaction for replay (including the transaction hash, the abi of the transaction creation contract) | Y | N |
Unit Test | Y | N |
import project | Import projects from local and other sources, such as github, gist, ipfs, etc. | Built-in smart contract template, operate on the Project page |
Account browser | N | Y Enter the account address in the address bar of the Explorer page to view |
database:
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。