createPayloadForNearMPC method
Future<MpcTransactionInfo>
createPayloadForNearMPC({
- required String receiverAddress,
- required double amount,
- required EVMTransactionInfo transactionInfo,
- String? smartContractCallEncoded,
- String typeOfNetwork = "testnet",
Create payload for Near MPC using Ethereum data
The receiver address is the address of the recipient of the transaction. The amount is the amount of ETH to send. The transaction info is the necessary information to create an unsigned transaction. The smart contract call encoded is the encoded smart contract call. The type of network is the network type (testnet or mainnet).
Implementation
Future<MpcTransactionInfo> createPayloadForNearMPC({
required String receiverAddress,
required double amount,
required EVMTransactionInfo transactionInfo,
String? smartContractCallEncoded,
String typeOfNetwork = "testnet",
}) async {
final amountInWei = EthereumFormater.convertEthToWei(amount);
final chainId = typeOfNetwork == "testnet" ? 43113 : 43114;
final Map<String, dynamic> chainInfo = {
"name": "avalanche",
"chainId": chainId,
};
final unsignedTransactionData = await jsVMService.callJS(
"""window.EVMUtils.createUnsignedTransaction('$receiverAddress', $amountInWei,
'${jsonEncode(chainInfo)}', '${jsonEncode(transactionInfo)}',
${smartContractCallEncoded != null ? """'$smartContractCallEncoded'""" : 'undefined'} )""",
);
final unsignedTransaction =
json.decode(unsignedTransactionData) as Map<String, dynamic>;
return MpcTransactionInfo(transactionInfo: unsignedTransaction);
}