我试图创建一个Dapp与颤振,这创建一个区块链帐户使用用户提供的注册细节。我正在尝试使用web3dart包并使用ganache服务器。
发布于 2022-10-02 11:34:24
首先,您需要连接到本地ganache网络:
import 'package:http/http.dart'; //You can also import the browser version
import 'package:web3dart/web3dart.dart';
var apiUrl = "http://localhost:7545"; //Replace with your API
var httpClient = Client();
var ethClient = Web3Client(apiUrl, httpClient);在你连接之后,就像和其他网络互动一样。您可以通过以下方式在此网络上创建新凭据:
var rng = Random.secure();
Credentials random = EthPrivateKey.createRandom(rng);
// In either way, the library can derive the public key and the address
// from a private key:
var address = await credentials.extractAddress();
print(address.hex);https://ethereum.stackexchange.com/questions/136723
复制相似问题