Skip to content

Instantly share code, notes, and snippets.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@pythnetwork/pyth-sdk-solidity/IPyth.sol";
import "@pythnetwork/pyth-sdk-solidity/PythStructs.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
// Example oracle AMM powered by Pyth price feeds.
//
// The contract holds a pool of two ERC-20 tokens, the BASE and the QUOTE, and allows users to swap tokens
pragma solidity ^0.5.0;
contract MetaCoinClonable {
mapping (address => uint) balances;
function initialize(address metaCoinOwner, uint256 initialBalance) public {
balances[metaCoinOwner] = initialBalance;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
pragma solidity ^0.5.0;
contract MetaCoin {
mapping (address => uint) balances;
constructor(address metaCoinOwner, uint256 initialBalance) public {
balances[metaCoinOwner] = initialBalance;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
function mintWithRoyalty(address recipient, string memory uri, address royaltFeeReceiver, uint96 fee) public returns(uint256){
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(recipient, tokenId);
_setTokenURI(tokenId, uri);
_setTokenRoyalty(tokenId, royaltFeeReceiver, fee);
return tokenId;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.7.2/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.7.2/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@4.7.2/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts@4.7.2/access/Ownable.sol";
import "@openzeppelin/contracts@4.7.2/utils/Counters.sol";
import "@openzeppelin/contracts@4.7.2/token/common/ERC2981.sol";
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts@4.7.3/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts@4.7.3/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts@4.7.3/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts@4.7.3/access/Ownable.sol";
import "@openzeppelin/contracts@4.7.3/utils/Counters.sol";
contract RoyaltyNFT is ERC721, ERC721Enumerable, ERC721URIStorage, Ownable {
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract Params is Initializable,OwnableUpgradeable {
function initialize()public initializer{
__Context_init_unchained();
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
contract Params is Initializable,OwnableUpgradeable {
function initialize()public initializer{
__Context_init_unchained();
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an
* explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
/**
* @dev This contract implements a proxy that is upgradeable by an admin.
*
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector