Closed saarshah closed 4 years ago
You can try Conflux CLI.
BTW, when deploy a smart contract, please double confirm if the outcomeState
in corresponding receipt is 0 (success).
thanks a lot , i will try ...
@boqiu How to get balance into our accounts , which are locally generated ? Are there any default accounts (with balances) which we can used for contract deployment and other transactions... ???
I suppose that you already created accounts at local machine via Conflux CLI (e.g. ./conflux account new). Now, you can transfer CFX to the new created local account via online wallet. Besides, you could also import external account to manage at local machine.
conflux accounts import --import-path <key_file_path>
When you use wallet to create an account, the key file will be downloaded at any place you specified.
Thanks for your prompt reply, I have done in both ways (1. send through Online wallet, and 2. Import through key file of my wallet). After that , i have check that accounts (where i transfer CFX and whose key file i have imported), the result is below;
However, i am still confused that how my local client know about online wallet transactions ? Is is connected to online wallet, even being a local client ???
The conflux rpc sub-commands are used to interact with Conflux node via JSON-RPC protocol. When you use CLI to query balance at local machine, you're asking the balance on your local Conflux node. I think that you did not connect the testnet (by specifying the bootnodes in testnet), so you got zero.
Please note, the wallet and scan are all connect to the testnet. So, you should also connect to the testnet and try the experiment above again.
Sorry, "you did not connect the testnet (by specifying the bootnodes in testnet)" , I could not got this point. Will you explain me further. You means that in order to run local node, still i need to connect o testnet ???. then i think, i will not got my transactions immediately (as like Ganache, if i am not on wrong direction).. ? BTW: How could i specify bootnodes in testnet ?
When you launch the Conflux node with default configuration file (default.toml), it will connect to the testnet automatically. Because, the testnet bootnodes are already configured in default.toml file.
If you want to launch a private Conflux node, a simple way is to remove the bootnodes configurations in default.toml file. However, as far as I know, there are some bugs that blocking the startup of Conflux node. Now, private network enablement has low priority, you'd better to still use testnet before we fix that problem.
thanks , but my all work depend on private conflux node, because i have to run lot of transaction and need immediate results , which is not possible in testnet.
BTW. i have used following config.conf file (instead of default.toml) to run my local node. Is it possible to insert some lines in that file in order to run local node and connect to testnet ? config.conf
port=12539
# jsonrpc_tcp_port=12536
jsonrpc_http_port=12537
# jsonrpc_local_tcp_port=12538
jsonrpc_local_http_port=12539
log_file='/Users/amirali/node0/conflux.log'
test_mode=true
log_level="debug"
storage_cache_size=200000
storage_cache_start_size=200000
storage_node_map_size=200000
start_mining=false
p2p_nodes_per_ip=0
To connect to the testnet, please refer to the bootnodes in default.toml configuration file. Then, the test_mode
should be set to false.
If you have to test with a private Conflux node, then you can call generate_block(num_txs, max_block_size)
to generate a block under test mode
only. I noticed that you have already specified test_mode=true
in your own configuration file.
now I become totally confused ! . Let me try to explain my question, may be i could not elaborate my question well. Currently, i have local accounts (with zero balance) and running my local node without connected to testnet.
Maybe you can try to configure genesis accounts, which are used for our internal experiment only:
genesis_secrets="./xxx.toml"
In this way, you can configure any genesis accounts as you want. In addition, each configured genesis account's balance is 10,000 CFX as hardcoded for experiment purpose only. Anyway, it is enough for your test.
As for the address of genesis account, it is calculated as keccak(public_key)[12:32]
Thanks for your guidance ,now i have successfully, configure accounts with balances and can confirm it through CLI. However, as you said earlier, yes there are bugs/errors , but not in startup. My node running, but i could not deploy smart contract on my local node. At first, i received following errors;
When i used contract.constructor(...).estimateGas(); it gives following error
RPCError: Internal error
at HttpProvider.call (C:\Users\amirali\Desktop\temp\node_modules\conflux-web\lib\provider\http.js:44:13)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Conflux.estimateGas (C:\Users\amirali\Desktop\temp\node_modules\conflux-web\src\conflux.js:666:20)
at async deployCon (C:\Users\amirali\Desktop\temp\myCaseDeploy.js:180:27)
at async main (C:\Users\amirali\Desktop\temp\myCaseDeploy.js:149:26) {
code: -32603
When i give estimated gas as hard coded, then my program shows calling of method namely cfx_getTransactionReceipt
again and again without any result...
{
data: {
jsonrpc: '2.0',
id: '15748226546811516052',
method: 'cfx_getTransactionReceipt',
params: [
'0xb6b688f2c8f9d0314fa53a9113adcdc0e2bd2a0bc71bf524a19acf8845aa8947'
]
},
result: null,
duration: 8
}
It is supposed that at local node (being test node), any transaction should be confirmed with result, immediately. Why the same case is not with Conflux ?
For question 1, the internal error of estimateGas, @GeekBerry please help on.
For question 2, I know you specify test mode in your configuration file. As I mentioned above, you need to call RPC generateoneblock
to generate block to pack the transaction. Otherwise, the sent transaction will be pending in transaction pool all the time.
#[rpc(name = "generateoneblock")]
fn generate_one_block(
&self, num_txs: usize, block_size_limit: usize,
) -> RpcResult<H256>;
Conflux has deferred execution mechanism, and you need to generate 5 blocks to ensure the sent transaction executed. Then, you can get the corresponding receipt via cfx_getTransactionReceipt
Internal error is a json-rpc error, that mean before full node received and after provider send, some thing wrong with json rpc call.
code | message | meaning |
---|---|---|
-32700 | Parse error | Invalid JSON was received by the server.An error occurred on the server while parsing the JSON text. |
-32600 | Invalid Request | The JSON sent is not a valid Request object. |
-32601 | Method not found | The method does not exist / is not available. |
-32602 | Invalid params | Invalid method parameter(s). |
-32603 | Internal error | Internal JSON-RPC error. |
-32000 to -32099 | Server error | Reserved for implementation-defined server-errors. |
Can you repeat this error? If you can, please paste json log for us.
@boqiu : You means i have to generate block and then pack my transactions, then send it through RPC API ? Then, its means there is no directly support of JavaScript APIs like web3js (in ethereum) .
@GeekBerry JSON logs ? How could i got this ? I have a log file as per my config.conf file (see above at first comment ), where i just see following lines
2019-11-27T11:25:33.731855800+08:00 DEBUG jsonrpc-eventloop-0 client::rpc: - RPC Request: cfx_estimateGas
2019-11-27T11:25:33.731855800+08:00 WARN jsonrpc-eventloop-0 client::rpc: - Transaction execution error "execution error: NotEnoughBaseGas { required: 113512, got: 100000 }"
@saarshah web3js do not have API to generate a block, which is usually generated by mining. Anyway, you could use curl to send a post request to your local Conflux node.
I think, we should don't need to generate block, it should be done by local node itself. If i have a local client running, then i think that all the mining related activities (generation of blocks, packing transactions, etc.) should be done automatically by node itself upon receiving/executing my code.... For example, i have tested my JavaScript program for ethereum local node (ganache), then i just send my transaction through .js program, ganache make a block and pack my transaction into it, by itself.
How to generate a block with packed transactions? Generally, there're 2 ways:
Anyway, we will support private network for test purpose when the mining algorithm finalized:
thanks for your all clarifications. Yes, exactly, I need such kind of private network for test purpose ... I hope it will be provided soon !...
I want to interact with localhost, instead of
http://testnet-jsonrpc.conflux-chain.org:12537'
, in order to get responses of lot of transactions immediately without any delay. I have deployed conflux locally as below;then make a .conf file for test mode with following parameters
then open a cmd terminal and run conflux with this command
conflux --config \Users\amirali\node0\conflux.conf
then i run my codenode deploy.js
, which give this errorhere is my code:
Is there any ganache (GUI or CLI) like test client to make local environment and uses local accounts balances to deploy contracts/send transaction. If yes, please share the procedure.