current position:Home>The Syntax version of Ethereum DAPP development practical video tutorial?
The Syntax version of Ethereum DAPP development practical video tutorial?
2022-02-03 20:53:49 【Q & A of Denglian community】
Reference resources “51CTO watch DAPP” Developing actual combat , Because the video tutorial is recorded early , In the process of learning and writing, with the current WEB3.js Different versions , There are multiple methods during the execution of the browser, which cannot be found , Source code attached , Please also advise which methods need to be modified , Can run through as soon as possible .
<html><head> <meta charset="UTF-8"> <title>First DAPP Demo</title> <link rel="stylesheet" type="text/css" href="main.css"> <script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script></head><body> <div class="container"> <h1>First DAPP Demo</h1> <h2 id="info"></h2> <label> full name :</label> <input id="name" type="text"> <label> Age :</label> <input id="age" type="text"> <button id="button"> Update the content </button> </div> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script> console.log("web3:" + web3); if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } else { web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); } // Get contract variables var infoContract = new web3.eth.Contract([{ "constant": true, "inputs": [], "name": "getInfo", "outputs": [{ "name": "", "type": "string" }, { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "name": "_name", "type": "string" }, { "name": "_age", "type": "uint256" } ], "name": "setInfo", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" } ]); var info = infoContract.at('0xda873b8dd76c861723e869269bc13a5a2999208f'); info.getInfo(function(error, result) { if (!error) { $("#info").html(result[0] + ' ( ' + result[1] + ' years old )'); } }); $("#button").click(function() { var name = $("#name").var(); var age = $("#age").var(); info.setInfo(name, age, function(error, result) { if (!error) { console.console.log("set ok");; } }) }); </script></body></html>
Take the answer 1:
Code updated :
copyright notice
author[Q & A of Denglian community],Please bring the original link to reprint, thank you.
https://en.netfreeman.com/2022/02/202202032053474296.html
The sidebar is recommended
- How to convert bytes type into address type in solidity
- How to distinguish between contract address and ordinary account address?
- Convert uint to bytes in solidity
- What does gas in Ethereum mean?
- How is the Ethereum contract address calculated?
- What Ethereum projects are suitable for beginners to learn solidity?
- Why create a new contract language, solid, instead of using other existing languages
- Can I get the hash of the transaction in the solidity function?
- How to delete an element at a certain position in an array in solidity?
- Does solid have a simple and universal storage model?
guess what you like
-
Solidity: what is the difference between 'view' and 'constant'?
-
How to determine whether a key exists in a mapping? Struct is defined in the library (in solidity).
-
How does Sha3 / keccak256 in solidity calculate the cell hash value?
-
Return and read a structure through Web3
-
How do I know the compiled version of solidity I'm using
-
What is an event?
-
Should we use the private matemask node
-
How to build a usdt wallet node based on erc20
-
ZK snark how to set CRS if there is cyclic logic in the circuit
-
Teacher, I got the value with Web3 according to your video tutorial, but when calling setinfo with Web3, an error is reported when the set value is set. What is the reason?
Random recommended
- When setting the default initiating account, the console reports an error: Web3 eth. defaultAccounts is not a function
- Accounts has been unable to get the local address.
- Metamask is connected to the local network. Why can't Web3 use the default address?
- Write the code in and still can't get the address. Is it related to my network? I've been using metamask reponste3 to test the network, but the local network 8545 can't be connected
- Setinfo is called successfully, but an error will be reported after success. What is the reason?
- Use the Ganache local node to prompt that the introduction of Web3 is successful. But you can't use Web3's method
- Solid returns cannot return results
- Why did I get an error initializing the genesis block.
- Why do I start the RPC service of geth node and send a request to the node without response from the terminal?
- How to solve the problem of displaying errors in the constructor of solidity because of the version of vs Code?
- The new version of truss initializes test with init. There are no files in test. Is it a version problem?
- What do you think of the time it takes to call a contract
- Problems encountered initializing folders with truss init. Prompt: how to solve the problem of unable to connect to the network
- What is the solution
- When compiling the contract, the terminal input truss compile is stuck and cannot be compiled successfully
- What is the problem that the version of the solid compiler cannot be matched after the truss compile prompt
- After downloading the truss again, the problem of Solc compiling environment will not be prompted, but the output error will be displayed. Why?
- Interact with the contract in the truss console, and call Web3 when passing parameters The toWei hint is not a function
- Building usdt wallet node based on erc20
- Why is there a promise syntax error when it is written like this? It shows that the listener function is undecided. Obviously, a contract instance has been successfully introduced.
- The wallet can be connected to metamask and Ganache to obtain balance, but the balance connected to get is 0
- How do contracts simulate the passage of time?
- How to use private key offline signature to initiate a contract call transaction?
- Why does nonce in eth trading have to be continuous? I think it's bigger than the current one. Please solve your doubts???
- When the third parameter is passed, the web console reports an error and votes for the third candidate. Metamask is not approved, but it is OK to delete the third parameter "Jose".
- How does solidity calculate the square root of a number?
- What's the use of solidity contract address?
- How to ensure that the information collected by each node is consistent in the generation of a block?
- How to use different users to call contract functions in truffle console
- How to use the call, callcode, and delegatecall functions called by the solidity contract?
- How to assign and deploy constructor parameters in geth console?
- How to use the keyword "solid payable"?
- How to construct offline transaction for bitcoin isolation address
- Ganache installation problem
- The "gas deduction" function appears in the "solid require" function?
- How does a smart contract receive Ethernet?
- Metamask transfer error
- Etherscan has been blocked. What alternative blockchain browser is available?
- Bitcoin 6 block confirmation problem
- When mining with code, why do you have to convert it into JSON format and sort it when hashing?