shhPost method
Future<bool?>
shhPost(
- List<
EthereumData> ? topics, - EthereumData? payload,
- int? priority,
- int? ttl, {
- required EthereumAddress to,
- required EthereumAddress from,
SHH post Sends a whisper message from: - (optional) The identity of the sender. to: - (optional) The identity of the receiver. When present whisper will encrypt the message so that only the receiver can decrypt it. topics: - List of topics, for the receiver to identify messages. payload: - The payload of the message. priority: - The integer of the priority in a range from ... (?). ttl: - integer of the time to live in seconds. Returns true if the message was send, otherwise false.
Implementation
Future<bool?> shhPost(List<EthereumData>? topics, EthereumData? payload,
int? priority, int? ttl,
{required EthereumAddress to, required EthereumAddress from}) async {
if (topics == null) {
throw ArgumentError.notNull('Ethereum::shhPost - topics');
}
if (payload == null) {
throw ArgumentError.notNull('Ethereum::shhPost - payload');
}
if (priority == null) {
throw ArgumentError.notNull('Ethereum::shhPost - priority');
}
if (ttl == null) {
throw ArgumentError.notNull('Ethereum::shhPost - ttl');
}
var params = <String, dynamic>{
'topics': EthereumData.toStringList(topics),
'payload': payload.asString,
'priority': EthereumUtilities.intToHex(priority),
'ttl': ttl,
'to': to.asString,
'from': from.asString
};
params = EthereumUtilities.removeNull(params) as Map<String, dynamic>;
final paramBlock = <dynamic>[params];
const method = EthereumRpcMethods.shhPost;
final dynamic res = await _client.rpcClient.request(method, paramBlock);
if (res != null && res.containsKey(EthereumConstants.ethResultKey)) {
return res[EthereumConstants.ethResultKey];
}
_client.processError(method, res);
return null;
}