joinCommunityOffChain method
Implementation
Future<Map<String, dynamic>> joinCommunityOffChain(
String walletAddress,
String communityAddress, {
String network = 'fuse',
String? originNetwork = 'mainnet',
String? tokenAddress,
String? communityName,
}) async {
String nonce = await getNonceForRelay();
print('nonce: $nonce');
DeployedContract contract = await _contract(
'CommunityManager',
_communityManagerContractAddress,
);
Uint8List data = contract.function('joinCommunity').encodeCall([
EthereumAddress.fromHex(walletAddress),
EthereumAddress.fromHex(communityAddress)
]);
String encodedData = '0x' + HEX.encode(data);
print('encodedData: $encodedData');
String signature = await signOffChain(
_communityManagerContractAddress,
walletAddress,
BigInt.from(0),
encodedData,
nonce,
BigInt.from(0),
BigInt.from(_defaultGasLimit),
);
return {
"walletAddress": walletAddress,
"methodData": encodedData,
"communityAddress": communityAddress,
"nonce": nonce,
"gasPrice": 0,
"network": network,
"gasLimit": _defaultGasLimit,
"signature": signature,
"walletModule": "CommunityManager",
"methodName": "joinCommunity",
"transactionBody": {
"tokenAddress": tokenAddress,
"originNetwork": originNetwork,
"status": 'pending',
"communityName": communityName,
}
};
}