Messages in Filecoin allow sending arbitrary values through the params
field.
- data to send through transactions should be base64 encoded when using the message sending APIs.
- note: you'll be sending to
method: 0
, which should be the default in your tools.method: 0
will ignore theparams
.
- assuming you have a configured
lotus
andlotus-shed
- assuming the data you want to send is
aGVsbG8=
(base64. or in hex:68656c6c6f
)
./lotus-shed rpc MpoolPushMessage '[{"From":"f3u27vs6zd3eesaevkawq4wo3emr45vu7cipjkbi5zgafko32aoebqikw7ohgsirdsenvsp73z6doogpoinwhq", "To": "f3wnmzhu5iln7shuawotkmbaejf6oabp7dits4t4p6zvwxeomqgewjpmp4ho4oyuxuga2gzwe7eu2nmw4prsjq", "Value": "1", "Params": "aGVsbG8="}, {"MaxFee": "70000000000000000"}]'
{"jsonrpc":"2.0","result":{"Message":{"Version":0,"To":"f3wnmzhu5iln7shuawotkmbaejf6oabp7dits4t4p6zvwxeomqgewjpmp4ho4oyuxuga2gzwe7eu2nmw4prsjq","From":"f3u27vs6zd3eesaevkawq4wo3emr45vu7cipjkbi5zgafko32aoebqikw7ohgsirdsenvsp73z6doogpoinwhq","Nonce":834,"Value":"1","GasLimit":592085,"GasFeeCap":"10511865265","GasPremium":"99612","Method":0,"Params":"aGVsbG8=","CID":{"/":"bafy2bzacedtrbj3j2kr7jjlpselfilae634rhfn6k7qmllfsyyfqnnbmqory6"}},"Signature":{"Type":2,"Data":"kFXCBa52x4QMamFDEfn36IqGCo+Zbst+3nnj6N+zuHq/8KsZZW5VykMw4ChhioxSCs9+u44yinnnsYxYdWcpvqgh2oQXvdFvabqoluavh8bhZl6OgbD6p9dS60zzNwtK"},"CID":{"/":"bafy2bzacedtrbj3j2kr7jjlpselfilae634rhfn6k7qmllfsyyfqnnbmqory6"}},"id":0}
- result: https://filfox.info/en/message/bafy2bzacedtrbj3j2kr7jjlpselfilae634rhfn6k7qmllfsyyfqnnbmqory6
- TODO: show an example here of signing the message outside, and using
MPoolPush
filecoin.js example
- using filecoin.js, assuming you have set it up (see their docs)
- you should be able to do something like this:
const msgVals = {
To: <to-addr>,
From: <from-addr>,
Value: new BigNumber(<amount>),
Params: <base64-encoded-params>, // todo: check if this is base64 encoded string, or a Buffer
}
const message = await walletProvider.createMessage(msgVals);
const signedMessage = await walletProvider.signMessage(message);
const msgCid = await walletProvider.sendSignedMessage(signedMessage);
js-lotus-client example
- TODO: write an example w/ js-lotus-client
filecoin-signing-tools example
- TODO: write an example w/ filecoin-signing-tools
- borrow from: https://github.com/Zondax/filecoin-signing-tools/blob/master/examples/wasm_browser/index.js
there are a bunch of filecoin node hosted services. see:
- https://docs.filecoin.io/build/hosted-lotus/ (glif nodes)
- https://infura.io/docs/filecoin
- (add yours in the comments)