Giter Club home page Giter Club logo

Comments (2)

linhpn99 avatar linhpn99 commented on June 30, 2024

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

from gno.

linhpn99 avatar linhpn99 commented on June 30, 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

from gno.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.