Avatar
0
monkey Enlightened
monkey Enlightened
Danh sách các boot nodes của ethereum ...
Danh sách các boot nodes của ethereum ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
web3 js sử dụng hàm sign và hàm ecRecover làm chức năng đăng nhập ...
Những anh em nào yêu thích hoặc đã quen với lập trình javascript có thể sử dụng thư viện web3 js để làm cơ chế đăng nhập thông qua hàm sign và ecRecover , ví dụ: const Web3 = require('web3'); const fs = require('fs'); const Strings = require('./strings'); let provider = new Web3.providers.HttpProvider("http://localhost:8545/"); let web3 = new Web3(provider); ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Sử dụng tài khoản ethereum để login cho các ứng dụng khác ...
Ethereum nói riêng hay blockchain nói chung đều sử dụng chữ ký số để ký và xác thực giao dịch, vậy nên chúng ta cũng có thể tận dụng cơ chế này cho phép người dùng có địa chí tài khoản etherum tạo được tài khoản trên hệ thông của chúng ta, các bước bao gồm: Người dùng tạo một mật khẩu bất kỳ, chuyển mật khẩu này về dạng hex, sau đó ký với password này, ví dụ: ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Ethereum gas limit và gas price dùng để làm gì? ...
Trong ethereum thì gas limit và gas price dùng để tính ra tiền phí (eth) mà một giao dịch phải trả. Từ tháng 8 2021 thì cách tính phí giao dịch sẽ kiểu này: Giả sử Alice gửi cho Bob 1 ETH với gas limit 21,000 units và gas price là 200 gwei , thì tổng tiền phí sẽ là: Gas units (limit) Gas price per unit i.e 21,000 200 = 4,200,000 gwei hoặc 0.0042 ETH Khi Alice ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Tạo một giao dịch chuyển tiền trong mạng ethereum private ...
Để tạo một giao dịch chuyển tiền trong mạng ethereum private, chúng ta có thể thực hiện các bước sau: Tạo sẵn 1 tài khoản với mật khẩu tuỳ ý, ví dụ 123 Khởi tạo 1 mạng private với genesis block và tài khoản vừa tạo kiểu thế này: { "config": { "chainID" : 10, "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0 }, "difficulty": "1", "gasLimit": ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Deploy ERC20 (smart contract cho ICO) lên mạng private ...
Dể deploy ERC20 (smart contract cho ICO) lên mạng private, chúng ta cần trải qua các bước sau: Tải ERC20 contract tại đây Sửa file truffle-config.js thế này: module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*", gas: 0, from: "0x3c31b4b9d6c24bad29498f99aaa6914231362c7f" } }, compilers: { solc: { version: "0.7.6" } } }; ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Sử dụng smart contract trong mạng etherum với web3js ...
Giả sử contract của chúng ta có nội dung thế này: // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Migrations { string public _message; uint public _last_completed_migration; function Hello() public{ _message = "Hello World!"; } function setCompleted(uint completed) public { _last_completed_migration = completed; } function ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Deploy contract lên mạng Ropsten test net ...
Để deploy contract lên mạng Ropsten test net, chúng ta cần thực hiện các bước sau: Tạo project truffle tạo thư mục truffle: mkdir truffle cd truffle truffle init Cập nhật file Migrations.sol // SPDX-License-Identifier: MIT pragma solidity >=0.4.22 <0.9.0; contract Migrations { string public message; uint public last_completed_migration; function Hello() ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Tạo ethereum smart contract đơn giản trong mạng private ...
tạo file genesis.json { "config": { "chainId": 15, "homesteadBlock": 0, "eip150Block": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0, "constantinopleBlock": 0 }, "difficulty": "400000", "gasLimit": "2100000", "alloc": {} } khởi tạo blockchain: geth --datadir . init genesis.json khởi động node geth --syncmode fast --allow-insecure-unlock --cache ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Tạo một ethereum chain mới ...
Chạy geth thông tường Tạo sẵn 2 tài khoản Tắt geth đi Tạo một thư mục mới ví dụ /Users/monkey/geth Tạo 1 genesis block trong thư mục /Users/monkey/geth kiểu: { "config": { "chainId": 15, "homesteadBlock": 0 }, "difficulty": "1", "gasLimit": "9999999", "nonce": "0xdeadbeefdeadbeef", "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", ...
Answer
Avatar
0
monkey Enlightened
monkey Enlightened
Tạo tài khoản ethereum cho dev ...
Để tạo tài khoản ethereum qua HTTP bạn có thể dùng câu lệnh này: curl --location --request POST 'http://localhost:8545/' \ --header 'Content-Type: application/json' \ --data-raw '{ "jsonrpc":"2.0", "method":"personal_newAccount", "params":["password"], "id":1 }' Chi tiết hơn bạn có thể tham khảo tại đây . Sau khi tạo tài khoản xong thì thông tin tài khoản sẽ ...
Answer
Avatar
1
monkey Enlightened
monkey Enlightened
Bắt đầu làm quen với ethereum từ đâu ...
Pull geth về và làm theo hướng dẫn tại README.md để build Chạy câu lệnh này sau khi build xong để enable http api: ./build/bin/geth --http --http.api personal,eth,net,web3 Gọi thử 1 vài API đã được tổng hợp sẵn trên postman Tham khảo tài liệu chính thức của ethereum Hỏi stackask nếu bạn có bất kì thắc mắc nào. ...
Answer