Learn how to fetch the Moxie earning details of casts and replies and how it is split among the casters and fan token holders.
Introduction
The Moxie Protocol enables Farcaster Members to earn Everyday Rewards based on who engages with their casts. These rewards are automatically split as follows:
To access the Airstack APIs in other languages, you can use https://api.airstack.xyz/gql as your GraphQL endpoint.
Get User's Casts With Their Moxie Earning Details
You can use the FarcasterCasts API to fetch all user's casts and get their Moxie earning details by providing the FID of the user to the castedBy filter input:
Try Demo
Code
queryMyQuery { FarcasterCasts( input: {filter: {castedBy: {_eq: "fc_fid:602" # Specify user's FID here } },blockchain: ALL } ) { Cast { hash # Get the moxie earning details here moxieEarningsSplit { earnerType earningsAmount earningsAmountInWei } } }}
{"data": {"FarcasterCasts": {"Cast": [ {"hash":"0x34e6bbb99b9166bc2098e109a328bdfd1dfaa207","moxieEarningsSplit": [ {// Earnings for the caster"earnerType":"CREATOR","earningsAmount":0.052771409349,"earningsAmountInWei":"52771409349000000" }, {// Earnings for the channel fan token holders"earnerType":"CHANNEL_FANS","earningsAmount":0.00338907949,"earningsAmountInWei":"3389079490000000" }, {// Earnings for the Farcaster network token holders"earnerType":"NETWORK","earningsAmount":0.008022926977,"earningsAmountInWei":"8022926977000000" }, {// Earnings for the fan token holders"earnerType":"CREATOR_FANS","earningsAmount":0.016045853954,"earningsAmountInWei":"16045853954000000" } ] },// Other casts ] } }}
If moxieEarningSplit is returned as null, then it implies that the cast has not earned any Moxie.
Get User's Replies With Their Moxie Earning Details
You can use the FarcasterReplies API to fetch all user's replies and get their Moxie earning details by providing the FID of the user to the repliedBy filter input:
Try Demo
Code
queryMyQuery { FarcasterReplies( input: {filter: {repliedBy: {_eq: "fc_fid:602"} # Specify user's FID here },blockchain: ALL } ) { Reply { hash # Get the moxie earning details here moxieEarningsSplit { earnerType earningsAmount earningsAmountInWei } } }}
{"data": {"FarcasterReplies": {"Reply": [ {"hash":"0x8db996f6515509d32fc1524740b8010839ca754b","moxieEarningsSplit": [ {// Earnings for the Farcaster network fan token holder"earnerType":"NETWORK","earningsAmount":0.040443829698,"earningsAmountInWei":"40443829698000000" }, {// Earnings for the caster"earnerType":"CREATOR","earningsAmount":0.283106807886,"earningsAmountInWei":"283106807886000000" }, {// Earnings for fan token holders"earnerType":"CREATOR_FANS","earningsAmount":0.080887659396,"earningsAmountInWei":"80887659396000000" } ] },// Other replies ] } }}
If moxieEarningSplit is returned as null, then it implies that the cast has not earned any Moxie.
Get All Cast In A Channel And Their Moxie Earning Details
You can use the FarcasterCasts API to fetch all the casts casted in a certain channel and get their Moxie earning details by providing the channel URL to the rootParentUrl filter input:
Try Demo
Code
queryMyQuery { FarcasterCasts( input: {filter: {rootParentUrl: { # Specify channel URL here_eq: "https://warpcast.com/~/channel/airstack" } },blockchain: ALL } ) { Cast { hash # Get the moxie earning details here moxieEarningsSplit { earnerType earningsAmount earningsAmountInWei } rootParentUrl } }}
{"data": {"FarcasterCasts": {"Cast": [ {"hash":"0x5cfb536eceeebb9fa54b8390ff4fc1e5eba582cc","moxieEarningsSplit": [ {"earnerType":"CREATOR","earningsAmount":0.056955485088,"earningsAmountInWei":"56955485088000000" }, {"earnerType":"NETWORK","earningsAmount":0.006328387232,"earningsAmountInWei":"6328387232000000" } ],"rootParentUrl":"https://warpcast.com/~/channel/airstack" },// Other casts in /airstack channel ] } }}
If moxieEarningSplit is returned as null, then it implies that the cast has not earned any Moxie.
Get Certain Cast Moxie Earning Details
You can use the FarcasterCasts API to fetch a certain cast and get its Moxie earning details by providing the cast hash to the hash filter input:
Try Demo
Code
queryMyQuery { FarcasterCasts( input: {filter: {hash: { # specify the cast hash here_eq: "0x34e6bbb99b9166bc2098e109a328bdfd1dfaa207" } },blockchain: ALL } ) { Cast { hash # Get the moxie earning details here moxieEarningsSplit { earnerType earningsAmount earningsAmountInWei } } }}
{"data": {"FarcasterCasts": {"Cast": [ {"hash":"0x34e6bbb99b9166bc2098e109a328bdfd1dfaa207","moxieEarningsSplit": [ {// Earnings for the caster"earnerType":"CREATOR","earningsAmount":0.052771409349,"earningsAmountInWei":"52771409349000000" }, {// Earnings for the channel fan token holders"earnerType":"CHANNEL_FANS","earningsAmount":0.00338907949,"earningsAmountInWei":"3389079490000000" }, {// Earnings for the Farcaster network token holders"earnerType":"NETWORK","earningsAmount":0.008022926977,"earningsAmountInWei":"8022926977000000" }, {// Earnings for the fan token holders"earnerType":"CREATOR_FANS","earningsAmount":0.016045853954,"earningsAmountInWei":"16045853954000000" } ] } ] } }}
If moxieEarningSplit is returned as null, then it implies that the cast has not earned any Moxie.
Get Certain Reply Moxie Earning Details
You can use the FarcasterReplies API to fetch a certain reply and get its Moxie earning details by providing the cast hash to the hash filter input:
Try Demo
Code
queryMyQuery { FarcasterReplies( input: {filter: {hash: { # specify the reply cast hash here_eq: "0x8db996f6515509d32fc1524740b8010839ca754b" } },blockchain: ALL } ) { Reply { hash # Get the moxie earning details here moxieEarningsSplit { earnerType earningsAmount earningsAmountInWei } } }}
{"data": {"FarcasterReplies": {"Reply": [ {"hash":"0x8db996f6515509d32fc1524740b8010839ca754b","moxieEarningsSplit": [ {// Earnings for the Farcaster network fan token holder"earnerType":"NETWORK","earningsAmount":0.040443829698,"earningsAmountInWei":"40443829698000000" }, {// Earnings for the caster"earnerType":"CREATOR","earningsAmount":0.283106807886,"earningsAmountInWei":"283106807886000000" }, {// Earnings for fan token holders"earnerType":"CREATOR_FANS","earningsAmount":0.080887659396,"earningsAmountInWei":"80887659396000000" } ] } ] } }}
If moxieEarningSplit is returned as null, then it implies that the cast has not earned any Moxie.
Developer Support
If you have any questions or need help regarding fetching Moxie earnings details data on Farcaster casts and replies, please join our Airstack's Telegram group.