Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Integrate Sponsor Mechanism for Transaction Fees #2152

Open
linhpn99 opened this issue May 20, 2024 · 2 comments
Open

Proposal: Integrate Sponsor Mechanism for Transaction Fees #2152

linhpn99 opened this issue May 20, 2024 · 2 comments

Comments

@linhpn99
Copy link
Contributor

linhpn99 commented May 20, 2024

Description

Summary

I propose the addition of a sponsorship mechanism for transaction fees on Gno.land, allowing third-party addresses to cover gas fees for transactions. This feature would enhance user experience by enabling transactions without requiring the sender to have sufficient funds for gas, similar to the Gas Station Network (GSN) on Ethereum.

Motivation

The primary motivation behind this proposal is to lower the barrier to entry for new users and improve usability. By allowing sponsors to pay for transaction fees, we can facilitate a smoother onboarding process for users who might not have native tokens but want to interact with the blockchain.

Usecase

  1. Onboarding New Users to Decentralized Applications (dApps): A new decentralized finance (DeFi) platform wants to attract users who are unfamiliar with blockchain technology. By sponsoring their initial transactions, the platform can allow users to explore its features without needing to acquire native tokens.

  2. Gaming and NFTs: A blockchain-based game wants to improve user retention by eliminating upfront costs associated with minting NFTs or participating in in-game transactions.

  3. Promotional Campaigns: A company launches a marketing campaign where users can claim digital collectibles or special offers through blockchain transactions.

  4. Subscription-Based Services: A subscription service for premium content or tools wants to offer a free trial period without users needing to handle transaction fees.

  5. Educational Platforms: An educational platform provides blockchain courses and wants to allow students to perform transactions as part of their learning without bearing the cost.

  6. Loyalty Programs and Rewards: A retail company implements a blockchain-based loyalty program where customers earn points for purchases that can be redeemed for rewards or discounts.

  7. Community and Governance Participation: A decentralized autonomous organization (DAO) wants to increase participation in its governance by eliminating the cost of submitting votes or proposals.

  8. Trialware and Freemium Models: A software provider offers a freemium model where basic features are free, but advanced features require a subscription.

Our Design

SponsorTransaction_Flow (3)

Security Considerations

  • Ensure that the sponsorship mechanism cannot be exploited for spam or malicious transactions.
  • Implement checks to prevent sponsors from being overdrawn or from sponsoring unauthorized transactions.

Testing:

  • Write unit tests to verify the correct handling of transactions with and without sponsors.
  • Conduct thorough testing in a local or testnet environment to ensure stability and security.

Benefits

  • Enhances user experience by allowing transactions without the need for users to hold native tokens for gas.
  • Encourages wider adoption and interaction with the Gno.land ecosystem.
  • Aligns with practices seen in other blockchain ecosystems, making Gno.land more competitive.

Potential Drawbacks

  • Increased complexity in transaction processing logic.
  • Additional considerations for securing and managing sponsorship accounts.

Conclusion

Integrating a sponsorship mechanism for transaction fees would significantly improve user accessibility and experience on Gno.land. I look forward to the community's feedback and discussion on this proposal.

References

Gas Station Network (GSN) on Ethereum
Sponsored Transactions on SUI

@linhpn99
Copy link
Contributor Author

Does our gno.land platform have the capability to implement technical solutions for the above problem ? @moul @zivkovicmilos

@linhpn99
Copy link
Contributor Author

linhpn99 commented May 24, 2024

According to the issue of creating paid transactions on behalf of others as discussed in the previous meeting, which VAR-META suggested, I have created a demo to test this feature:

  1. A sponsor account is set in the first message, responsible for paying the gas fee for the entire transaction (including the msg call below).
  2. A call to a realm function by the sender to execute the logic (expecting the account signing this message will not incur a fee).
  3. I sign the transaction for each account and arrange them in the order of the corresponding msg above.
var msgs = []std.Msg{
     vm.MsgCall{
         Caller:  sponsorInfo.Address,
         // PkgPath: "gno.land/r/demo/counter",
         // Func:    "Increase",
         // Args:    nil,
         // Send:    std.MustParseCoins("1000000ugnot"),
     },
     vm.MsgCall{
         Caller:  senderInfo.Address,
         PkgPath: "gno.land/r/demo/counter",
         Func:    "Increase",
         Args:    nil,
         // Send:    std.MustParseCoins("1000000ugnot"),
     },
 }
   tx.Signatures = append(tx.Signatures,
       std.Signature{
           PubKey:    sponsorPubKey,
           Signature: sponsorSignature,
       },
       std.Signature{
           PubKey:    senderPubKey,
           Signature: senderSignature,
       },
   )

However, the ValidateBasic() function in gno.land/pkg/sdk/vm/msgs.go does not allow sending an empty message:

func (msg MsgCall) ValidateBasic() error {
   if msg.Caller.IsZero() {
       return std.ErrInvalidAddress("missing caller address")
   }
   if msg.PkgPath == "" { // XXX
       return ErrInvalidPkgPath("missing package path")
   }
   if msg.Func == "" { // XXX
       return ErrInvalidExpr("missing function to call")
   }
   return nil
}

If it is necessary to call a function in the realm that does not have any logic in the first message, we still have to pay a small gas fee instead of not paying gas.

{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "height": "543",
    "results": {
      "deliver_tx": [
        {
          "ResponseBase": {
            "Error": null,
            "Data": "CgooMjAgdWludDY0KQoK",
            "Events": [
              {
                "@type": "/tm.gnoEvent",
                "type": "g1y490harzjqmdngmmaw4tyc4qdm5ma5k0fv3w6p : 20",
                "pkg_path": "gno.land/r/demo/counter",
                "func": "Increase",
                "attrs": null
              },
              {
                "@type": "/tm.gnoEvent",
                "type": "g1y490harzjqmdngmmaw4tyc4qdm5ma5k0fv3w6p : 20",
                "pkg_path": "gno.land/r/demo/counter",
                "func": "Increase",
                "attrs": null
              }
            ],
            "Log": "msg:0,success:true,log:,events:[]\nmsg:1,success:true,log:,events:[]",
            "Info": ""
          },
          "GasWanted": "1000000",
          "GasUsed": "274145"
        }
      ],
      "end_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        },
        "ValidatorUpdates": null,
        "ConsensusParams": null,
        "Events": null
      },
      "begin_block": {
        "ResponseBase": {
          "Error": null,
          "Data": null,
          "Events": null,
          "Log": "",
          "Info": ""
        }
      }
    }
  }
}

What should I do ? @jaekwon @leohhhn

Updated : this question is out-of-date

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

1 participant