問題:
“using tx.orgin would allow malign contracts to destroy your contract without your permission.”
摘錄來自: Andreas M. Antonopoulos. “Mastering Ethereum溺森∥组希” Apple Books.
原因:
調(diào)用鏈:用戶-> 合約A -> 合約B淘邻。
用戶調(diào)用合約A,可能只是想普通調(diào)用湘换,并不想銷毀合約B(假如合約B是由用戶創(chuàng)建)宾舅。但這時,如果使用 tx.origin 則會返回用戶地址彩倚,那么合約A 就可以銷毀合約B。假如使用 msg.sender, 則返回合約A的地址帆离,這時合約A想銷毀合約B是銷毀不了的。