DAPP互助拆分公排模式系統開發詳情丨DAPP技術框架

Lyr96246466發表於2023-05-11

  Web3是指一個基於區塊鏈技術的、開發-181公鏈2591合約開發3365微電去中心化的下一代網際網路。Web3將把網際網路從

中心化的模式轉變為去中心化的模式。這意味著,Web3不再依賴於中央機構來管理和控制網際網路,而是依賴於分散式網路和

自治系統來保護使用者的隱私和資料所有權。


  區塊鏈:Web3專案的去中心化協議。可以將其視為跟蹤所有交易的公共分類賬。目前,已經出現許多不同的區塊鏈技

術,各種各樣的專案和應用程式都可以在其中的每一種技術上執行。

web3.eth.accounts.create()

// > {

//    address: "0xb8CE9ab6943e0eCED004cDe8e3bBed6568B2Fa01",

//    privateKey: "0x348ce564d427a3311b6536bbcff9390d69395b06ed6c486954e971d960fe8709",

//    signTransaction: function(tx){...},

//    sign: function(data){...},

//    encrypt: function(password){...}

// };

  去中心化


  Web3的最大特點就是去中心化。傳統的Web2.0時代的網際網路是中心化的,掌握著使用者資料和使用者行為的權力都在中央機

構手中。而在Web3時代,網際網路將變得去中心化,資料的所有權和控制權將分散在多個節點之間,不再被單一機構所掌控。

const Web3 = require('web3');

const rpcURL = '' // Your RCP URL goes here const web3 = new Web3(rpcURL)

const web3 = new Web3(rpcURL);

const abi = [{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_releaseTime","type":"uint256"}],"name":"mintTimelocked","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]

const address = '0xd26114cd6EE289AccF82350c8d8487fedB8A0C07' ;

const contract = new web3.eth.Contract(abi, address); 

contract.methods.totalSupply().call((err, result) => { console.log(result) }); 

contract.methods.name().call((err, result) => { console.log(result) }); 

contract.methods.symbol().call((err, result) => { console.log(result) });

contract.methods.balanceOf('0xd26114cd6EE289AccF82350c8d8487fedB8A0C07').call((err, result) =>

{ console.log(result) }); // > Some large number...

智慧合約


智慧合約是Web3的重要組成部分,它可以在Web3的去中心化網路上實現自動化的交易和規則執行。智慧合約可以保證交易

的可靠性和安全性,避免人為干擾和欺詐。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70012429/viewspace-2951514/,如需轉載,請註明出處,否則將追究法律責任。

相關文章