Skip to content

Instantly share code, notes, and snippets.

View mradkov's full-sized avatar

mradkov

View GitHub Profile
@mradkov
mradkov / LogicalInversion.sol
Created March 15, 2018 13:46
Logical Inversion
pragma solidity ^0.4.21;
contract LogicalInversion {
bool state = true;
function LogicalInversion() public {
}
pragma solidity >=0.4.22 <0.6.0;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address private _owner;
pragma solidity >=0.4.22 <0.6.0;
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
pragma solidity >=0.4.22 <0.6.0;
import "./Ownable.sol";
/**
* @title Destructible
* @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
*/
contract Destructible is Ownable {
pragma solidity ^0.5.0;
import "./common/Ownable.sol";
import "./common/Destructible.sol";
import "./libs/SafeMath.sol";
contract DDNSService is Destructible {
/** USINGS */
using SafeMath for uint256;
@mradkov
mradkov / Destructible.sol
Created November 29, 2018 14:47
decentralized dns
pragma solidity >=0.4.22 <0.6.0;
import "./Ownable.sol";
/**
* @title Destructible
* @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
*/
contract Destructible is Ownable {
struct DomainDetails {
bytes name;
bytes12 topLevel;
address owner;
bytes15 ip;
uint expires;
}
struct Receipt {
uint amountPaidWei;
uint timestamp;
uint expires;
}
@mradkov
mradkov / DDNS-modifier-isAvailable
Created November 29, 2018 18:19
DDNS-modifier-isAvailable
modifier isAvailable(bytes memory domain, bytes12 topLevel) {
// @dev - get the domain hash by the domain name and the TLD
bytes32 domainHash = getDomainHash(domain, topLevel);
// @dev - check whether the domain name is available by checking if is expired
// if it was not registered at all the `expires` property will be default: 0x00
require(
domainNames[domainHash].expires < block.timestamp,
"Domain name is not available."
@mradkov
mradkov / DDNS-modifier-collectDomainNamePayments
Created November 29, 2018 18:35
DDNS-modifier-collectDomainNamePayments
modifier collectDomainNamePayment(bytes memory domain) {
// @dev - get the price for the provided domain
uint domainPrice = getPrice(domain);
// @dev - require the payment sent to be enough for
// the current domain cost
require(
msg.value >= domainPrice,
"Insufficient amount."