使用 dart 在基于以太坊的 Cleo 测试网中发布智能合约

问题描述

我正在尝试使用 dart 在 Celo alfajores testnet 中部署智能合约。我在“HelloWorld.json”中提取一个智能合约的最小 abi,​​它也包含字节码。我已经创建了一个地址并使用水龙头为地址添加了余额。现在我想使用 dart 部署合约。我正在使用 web3dart library。这是我的代码

import 'dart:typed_data';
import 'dart:io';
import 'package:http/http.dart';
import 'package:web3dart/web3dart.dart';
import 'package:path/path.dart' show join,dirname;
import 'dart:convert';

final File abiFile = File('HelloWorld.json');
void main(List<String> arguments) async {
  print("test");
  final abiCode = await abiFile.readAsstring();
  final jsonResponse = jsonDecode(abiCode);
  print(jsonResponse["bytecode"]);
  var rpcUrl =
      "https://alfajores-forno.celo-testnet.org"; //Replace with your API
  final client = Web3Client(rpcUrl,Client());

  final credentials = await client.credentialsFromPrivateKey(
      "0x20498351837bf81dd55a5dcc598b08c93b44b0202ccd9d1b6ccbb509a027a35f");
  final address = await credentials.extractAddress();
  print(address);
  print(await client.getBalance(address));
  List<int> list = utf8.encode(jsonResponse["bytecode"]);
  Uint8List bytes = Uint8List.fromList(list);
  await client.sendTransaction(
      credentials,Transaction(
        from: address,data: bytes),);
}

但是在尝试部署代码后出现以下错误(突出显示由我完成):

enter image description here

如何解决此问题并部署合约?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)