tx.origin

Solidity

परिभाषा

tx.origin वह address है जिसने originally transaction initiate किया (always एक EOA)। यह msg.sender से different है जो immediate caller हो सकता है (contract)। ⚠️ Security warning: tx.origin को authentication के लिए use न करें क्योंकि यह phishing attacks के लिए vulnerable है।

English version

tx.origin is the address that originally initiated the transaction (always an EOA). It differs from msg.sender which can be the immediate caller (contract). ⚠️ Security warning: don't use tx.origin for authentication as it is vulnerable to phishing attacks.

Code Example

// DANGEREUX : utilisation de tx.origin
function withdraw() public {
    require(tx.origin == owner); // VULNÉRABLE !
    // Un contrat malveillant peut tromper le owner
}

// SÉCURISÉ : utilisation de msg.sender
function withdrawSecure() public {
    require(msg.sender == owner); // Correct
}

संबंधित शब्द

Solingo पर इस concept को practice करें

tx.origin को interactive exercises और integrated IDE के साथ master करें।

मुफ्त में शुरू करें