Code Monkey home page Code Monkey logo

Comments (4)

vitiko avatar vitiko commented on August 17, 2024 1

invokeTransferFrom() is invoked not by token owner, but by spender, who have allowance to spend some amount from token owner, so:

  • invoker.GetMSPId(), invoker.GetId() - spender
  • fromMspId, fromCertId - owner
  • toMspId, toCertId - recipient

you can see example in test https://github.com/s7techlab/cckit/blob/master/examples/erc20/erc20_test.go#L101

from cckit.

vitiko avatar vitiko commented on August 17, 2024
// getAllowance gets amount of token allowed by wallet owner to spend by spender
func getAllowance(c r.Context, ownerMspId, ownerCertId, spenderMspId, spenderCertId string) (int, error) {
	return c.State().GetInt(allowanceKey(ownerMspId, ownerCertId, spenderMspId, spenderCertId), 0)
}

in the invokeTransferFrom() function

  • invoker.GetMSPID() and invoker.GetID() are spender requisites
  • fromMspId, fromCertId are wallet owner requisites

from cckit.

TedKang avatar TedKang commented on August 17, 2024
// getAllowance gets amount of token allowed by wallet owner to spend by spender
func getAllowance(c r.Context, ownerMspId, ownerCertId, spenderMspId, spenderCertId string) (int, error) {
	return c.State().GetInt(allowanceKey(ownerMspId, ownerCertId, spenderMspId, spenderCertId), 0)
}

in the invokeTransferFrom() function

  • invoker.GetMSPID() and invoker.GetID() are spender requisites
  • fromMspId, fromCertId are wallet owner requisites

you're right. I mean, it would be the token owner to invoke transferFrom() in the code above. So I think the Invoker's MspId should be placed in ownerMspId when calling getAllowance ().

What i understood...

in the invokeTransferFrom() function

  • invoker.GetMSPId(), invoker.GetId() >> token owner
  • fromMspId, fromCertId >> token Sender

Please reply if I misunderstand.

from cckit.

TedKang avatar TedKang commented on August 17, 2024

@vitiko Thanks for answer.
I misunderstood the concept.

from cckit.

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.