0

When transferring value within a function which one is best practices to do?

require(refundAddresses[x].send(refunds[refundAddresses[x]]))

refundAddresses[x].send(refunds[refundAddresses[x]
0

The second is an "unchecked" send, meaning the return value (bool) isn't checked.

So, the first one.

You can also do:

refundAddresses[x].transfer(refunds[refundAddresses[x]]);

... which will revert on failure, so does the check and reacts for you.

It looks suspiciously like part of an iterative process, e.g. for(x=0; x< .... Don't do it.

Hope it helps.

  • off topic, hope you will answer :) The operator used in mappings '=>' if this operator is used without spaces applied, will it then be understood as equal or larger than? e.g mapping(address => uint) public xx mapping(address=>uint) public yy – NowsyMe Jan 2 '18 at 1:13
  • No, it's just a syntax for saying the DHT maps an address to an unsigned integer. So uint y = xx[address] is the integer stored my an address. I never found a really good explainer for mappings, so I might turn your attention to "Basic Tools - Mappings" in this blog: medium.com/@robhitchens/solidity-crud-part-1-824ffa69509a – Rob Hitchens - B9lab Jan 2 '18 at 1:29
  • but this syntax has the same meaning regardless if written like this (x address=>uint) or (address => uint) the space between the syntax does not change the context? – NowsyMe Jan 2 '18 at 4:52
  • The spaces are unimportant. mapping(x address=>uint) myMap doesn't compile. The format is mapping(indexType => variableType) variableName and you can add the public modifier for a "free" getter, with some limitations. – Rob Hitchens - B9lab Jan 2 '18 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.