Position: Home page » Ethereum » Ethereum Web3 call contract

Ethereum Web3 call contract

Publish: 2021-05-28 02:36:12
1.

If you want to query the transaction records on the main network, you can use Etherscan. However, if you build your own private chain, how should you query the transaction records

the answer is that you need to listen to the logs on the chain, save them in the database, and then query them in the database. For example:

< pre t = "code" L = "Java" > varaddr = & quot& quot;< br />varfilter=web3.eth.filter({fromB lock:0 ,toBlock:' latest', address:addr });< br />filter.get(function(err,transactions){
transactions.forEach(function(tx){
vartxInfo=web3.eth.getTransaction(tx.transactionHash);
/ / at this time, the transaction information txinfo can be stored in the database
})< br />});

Web3. Eth. Filter() is used to monitor the log on the chain, and Web3. Eth. Gettransaction() is used to extract the information of the specified transaction. Once the transaction information is obtained, it can be stored in the database for query

recommend a practical introction, you can see: Ethereum tutorial

2. Gas & gt; ethestimateGas({ from:ethaccounts [1], to: ethaccounts[2], value:50000000000000 }) 21001 > Ethgasprice 2000000000, as shown above, shows this account [1] = & gt; The transaction of account [2] needs 21001 gas, and the current gasprice is 2000000000. How many gas does it take to send transaction / call contract method in Ethereum
3. Ethereum is a distributed computing platform. It generates an cryptocurrency called ether. Programmers can write "smart contracts" on the Ethereum blockchain, and these Ethereum smart contracts will be executed automatically according to the code

what is Ethereum
Ethereum is often compared with bitcoin, but the situation is different. Bitcoin is a kind of cryptocurrency and distributed payment network, which allows bitcoin to be transferred between users

related: what is bitcoin? How does it work

Ethereum has a bigger goal. As Ethereum says, "Ethereum is a distributed platform running smart contracts.". These smart contracts run on "Ethereum virtual machine", a distributed computing network composed of all devices running Ethernet nodes

"distributed platform" means that anyone can set up and run an Ethereum node just as anyone can run a bitcoin node. Anyone who wants to run "smart contracts" on nodes must pay the operators of these nodes in ether, which is a cryptocurrency related to Ethereum. Therefore, the person running the Ethernet node provides computing power and gets paid in the Ethernet, which is similar to the way that the person running the bitcoin node provides hash power and pays in bitcoin

in other words, although bitcoin is only a blockchain and payment network, Ethereum is a distributed computing network, and its blockchain can be used for many other things. Details are provided in the Ethereum white paper

what is ether
Ethernet is a digital token (or cryptocurrency) related to Ethereum blockchain. In other words, Ethereum is the token and Ethereum is the platform. But now people often use these terms alternately. For example, coinbase allows you to buy Ethereum, which stands for Ethereum

this is technically "altcoin", which actually means a non bitcoin cryptocurrency. Like bitcoin, ether is supported by distributed blockchain - in this case, Ethereum blockchain

developers who want to create applications or Ethereum smart contracts on Ethereum blockchain need Ethernet token to pay for nodes to host it, while users of Ethereum based applications may need Ethernet to pay for services in these applications. People can also sell services outside the Ethereum network and accept Ethernet payments, or they can sell Ethernet tokens in cash - just like bitcoin
4.

Yes, refer to the interaction between contracts. Digital currency exchange platform for example, I am trying to sign a smart contract from another factory contract and then redeploy the address of the new smart contract. However, the address it returns is the transaction hash, not the contract address. I believe this is because when the address is returned, the contract has not been exploited. When I deploy the smart contract with Web3, it seems that it will not output the contract address until the smart contract is deployed

5.

Generally speaking, the steps of deploying smart contract are as follows:


  1. start an Ethereum node (such as geth or testrpc)
  2. use Solc to compile smart contracts=& gt; Get the binary code
  3. deploy the compiled contract to the network This step will consume Ethernet currency, and you need to use the default address or specified address of your node to sign the contract.)=& gt; Get the blockchain address and ABI of the contract (JSON representation of the contract interface, including variables, events and callable methods) The author confused ABI with contract interface here. ABI is the binary representation of the contract interface.)
  4. use the JavaScript API provided by web3.js to call the contract Depending on the type of call, it may consume Ethernet currency.)

6. There is no inevitable relationship between whether the virtual currency will disappear or not and whether it can not be used on the third-party platform. Online third-party trading platform can only say that this kind of currency has another platform for trading, which shows that this kind of currency is more reliable
Ruitai coin has not been launched on the third-party platform, but it is rumored that it will also be launched on the third-party platform.
7. I've just seen Percy Jackson and the robber of divine fire. It's a bit like Harry Potter, but I think it's very good-looking. It's a story with Greek mythology
Percy Jackson is an ordinary 12-year-old boy who was diagnosed with dyslexia and hyperactivity disorder. During a field trip organized by the school, he was interviewed by his algebra teacher; Specific function & quot; Scared me. After that, Percy Jackson found that he was not an ordinary person, but a mythical figure and a descendant of human beings< After discovering the mystery of his life, Percy Jackson was sent to a special school. The children studying in this school are the offspring of many mythical characters. When Percy Jackson came to school, Poseidon immediately declared Jackson his own child. In this school, Percy Jackson met two good friends. One is the beautiful Annabeth chase, the descendant of Athena, the goddess of wisdom and skill; The other is Grover Underwood, a descendant of orcs. Not long in the school, Percy Jackson was accused by the gods of stealing the thunder rod of Zeus. Percy Jackson is required to hand over his thunder wand within 10 days, otherwise, his mother will be killed by these gods, and the war between the gods is inevitable...

there is still one minute left: three discriminated high school students have invented a time machine that allows them to go back in time and change their social status, And help other unfairly treated children to avoid the humiliation of discrimination in high school
twilight 2, new moon and 1 are about vampires. Bella (Kristen Stewart) is 18 years old and her father gives her a gift. Edward (Robert Pattinson) shows her love generously and tells her the legend of the Italian vampire king. Edward's red haired sister Alice (Ashley Greene, Ashley Greene) holds a birthday party specially for Bella. During the party, Bella accidentally cuts her arm and is attacked by Gaspar. Only with Edward's protection can she escape. However, since then, Edward graally alienated Bella and proposed to break up. This makes Bella cold, but Edward also has difficulties, still secretly protect Bella. Bella is in the empty window period, and her old friend Jacob (Taylor Lautner) makes a warm call, which makes their relationship warm up. Since then, Bella because of the cliff rescue, just know that Jacob is a werewolf, specialized in dealing with vampires. At the same time, Edward, who didn't know about it, thought Bella had committed suicide and was disheartened. He came to Italy to ask the royal family to end his life...

bloodthirsty daybreak, I think the ending is a little ironic
2012 is also very good, and the fantasy show of Arthur and his mini kingdom is also very good
8. The native API of JS and the API leaked by the browser can be tens of thousands of difficulties, let alone hundreds of thousands. If you are talking about calling the API of the desktop operating system, you can use nodejs. If you are talking about calling the API of the smartphone operating system, you can make the object encapsulation system API leaked by the WebView control, Or package your app with something like phonegap, you can call the API provided by it, and check the corresponding documents for the specific usage.

the working principle of nativscript: calling native API with JavaScript to realize cross platform
nativscript is a cross platform solution recently launched, which allows you to directly write Android and IOS local applications with JavaScript, It will be extended to Windows platform in the future. It's a project that has received more attention recently. It is essentially different from NW (formerly known as node WebKit, using web to write winodw / Linux desktop application) and phonegap embedded WebView to write app. It calls the system native API directly with JavaScript, so it has some native application characteristics.
9. Generally speaking, the steps of deploying smart contract are:
1 start an Ethereum node (such as geth or testrpc)
2 use Solc to compile smart contracts=& gt; Get the binary code
3 deploy the compiled contract to the network This step will consume Ethernet currency, and you need to use the default address or specified address of your node to sign the contract.)=& gt; Get the blockchain address and ABI of the contract (JSON representation of the contract interface, including variables, events and callable methods) The author confused ABI with contract interface here. ABI is the binary representation of the contract interface.)
4 use the JavaScript API provided by web3.js to call the contract Depending on the type of call, it may consume Ethernet currency.)
Hot content
Inn digger Publish: 2021-05-29 20:04:36 Views: 341
Purchase of virtual currency in trust contract dispute Publish: 2021-05-29 20:04:33 Views: 942
Blockchain trust machine Publish: 2021-05-29 20:04:26 Views: 720
Brief introduction of ant mine Publish: 2021-05-29 20:04:25 Views: 848
Will digital currency open in November Publish: 2021-05-29 19:56:16 Views: 861
Global digital currency asset exchange Publish: 2021-05-29 19:54:29 Views: 603
Mining chip machine S11 Publish: 2021-05-29 19:54:26 Views: 945
Ethereum algorithm Sha3 Publish: 2021-05-29 19:52:40 Views: 643
Talking about blockchain is not reliable Publish: 2021-05-29 19:52:26 Views: 754
Mining machine node query Publish: 2021-05-29 19:36:37 Views: 750