Casting
Explicit Casting Only
uint256 publicNumber = 100;
// Implicit casting -- will NOT compile
suint256 shielded = publicNumber; // Error
// Explicit casting -- correct
suint256 shielded = suint256(publicNumber); // OKbool flag = true;
sbool shieldedFlag = sbool(flag); // OK
address addr = msg.sender;
saddress shieldedAddr = saddress(addr); // OK
int256 signed = -42;
sint256 shieldedSigned = sint256(signed); // OK
bytes32 hash = keccak256("secret");
sbytes32 shieldedHash = sbytes32(hash); // OKShielding Values (Unshielded to Shielded)
Unshielding Values (Shielded to Unshielded)
Casting saddress to Payable
saddress to PayableSize Casting Between Shielded Integers
Common Patterns
Returning values from view functions
Interfacing with non-shielded contracts
Shielding input from encrypted calldata
Security Implications
Last updated

