sendTransaction method

Future<BlockchainResponse> sendTransaction(
  1. String txhex
)

Implementation

Future<BlockchainResponse> sendTransaction(String txhex) async {
  final res = await networkClient.postHTTP('', {
    "jsonrpc": "2.0",
    "method": "eth_sendRawTransaction",
    "params": [txhex],
    "id": "dontcare"
  });

  if (res.isSuccess) {
    if (res.data['error'] != null) {
      return BlockchainResponse(
        data: res.data['error'],
        status: BlockchainResponses.error,
      );
    }
    return BlockchainResponse(
      data: {"txHash": res.data['result']},
      status: BlockchainResponses.success,
    );
  } else {
    return BlockchainResponse(
      data: res.data,
      status: BlockchainResponses.error,
    );
  }
}