Skip to content

Instantly share code, notes, and snippets.

@casweeney
Created August 2, 2022 23:04
Show Gist options
  • Save casweeney/22a316c13c8a2380da55685c9f226a31 to your computer and use it in GitHub Desktop.
Save casweeney/22a316c13c8a2380da55685c9f226a31 to your computer and use it in GitHub Desktop.
Contract to typecast bytes32 to string
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TypeCasting {
bytes32 public x = "This is the beginning of Adddddd";
string public y = "This is the beginning of Adddddd";
function convertByteToString() public view returns(string memory) {
string memory result = string(abi.encodePacked(x));
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment