This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.6; | |
contract ContractA { | |
string internal tokenName = "FunToken"; | |
function initialize() external { | |
address contractBAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
did:3:kjzl6cwe1jw1497jm1ckqomr59zuprfmyjqqsk4mayxovtmgynx89x2ktfsvk69 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.17; | |
library LibPerson { | |
uint256 private constant INNER_STRUCT = 0; | |
struct Car { | |
string brand; | |
string model; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.11; | |
// Note: A facet is a contract used by a diamond. | |
// Note: This is a contrived example to show how to share internal functions between facets | |
// Note: It is not an accurate or complete implementation | |
// This design of sharing internal functions between facets works because remember the diamond proxy holds all the | |
// data and the facets read and write to the diamond proxy contract storage-- not to their own contract storage. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
DiamondStorage storage ds = diamondStorage(); | |
bytes4 functionSelector = bytes4(keccak256("myFunction(uint256)")); | |
// get facet address of function | |
address facet = ds.selectorToFacet[functionSelector]; | |
bytes memory myFunctionCall = abi.encodeWithSelector(functionSelector, 4); | |
(bool success, bytes memory result) = address(facet).delegatecall(myFunctionCall); | |
require(success, "myFunction failed"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.17; | |
struct Data { | |
uint a; | |
uint b; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity =0.8.9; | |
library MyLib { | |
function appStorage() | |
internal | |
pure | |
returns (AppStorage storage ds) | |
{ | |
assembly { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DiamondStorage storage ds = diamondStorage(); | |
bytes4 functionSelector = bytes4(keccak256("myFunction(uint256)")); | |
// get facet address of function | |
address facet = ds.selectorToFacet[functionSelector]; | |
bytes memory myFunctionCall = abi.encodeWithSelector(functionSelector, 4); | |
(bool success, uint result) = address(facet).delegatecall(myFunctionCall); | |
require(success, "myFunction failed"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.11; | |
import { LibDiamond } from "../libraries/LibDiamond.sol"; | |
import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; | |
import { IERC165 } from "../interfaces/IERC165.sol"; | |
import { IERC721 } from "../interfaces/IERC721.sol"; | |
contract Diamond { |
NewerOlder