Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save argctl/c35ae576ccbab7c0fd2ad5ba5e533d77 to your computer and use it in GitHub Desktop.
Save argctl/c35ae576ccbab7c0fd2ad5ba5e533d77 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.17+commit.8df45f5f.js&optimize=false&runs=200&gist=
pragma solidity ^0.8.4;
// a system that uses passwords or a real world artifact as an interface to verify timestamp and optionally location
// "they'll try to use your workspace"
// permissions :
// 1 - id for internal address
// 2 - password for internal address
// 3 - id, token => password // pseudo oauth
//
contract Gitarg {
event Log(string message);
event LogBytes(bytes data);
address private owner;
mapping (address => string) private hashs1;
mapping (address => string) private hashs2;
mapping (address => address) private hiddenAddresses;// address taken or because private address anyonomous check with map
mapping (address => bool) private internalAddresses; // addresses inside the gitarg system
mapping (string => address) private passwordToInternalAddress;
mapping (uint => address) private idToInternalAddress;
mapping (address => uint) private addressPermission;
mapping (address => uint) private codeExpiries;
//mapping (address => uint) public externalAddresses;
mapping (uint256 => uint) private idPrice; //might be private and then is potentially gambling unless we charge inquiry
mapping (address => bool) private allowPositive; // query function with price to find "creditor"
mapping (address => bool) private allowNegative; // query function with price to find "debitor"
mapping (uint256 => bool) private allowInstantSet;
mapping (uint256 => bool) private allowPriceSet;
mapping (uint256 => string) private idNetwork;
bool[] private temp;
uint startGlobal = 1666666666;
constructor() {
owner = msg.sender;
}
function setIdNetwork (uint256 id) external payable {
// id maps to internal address and internal address is key for hidden addresses to hide public address owner beyind query
require(msg.sender == hiddenAddresses[idToInternalAddress[id]]);
}
// should internalAddress be a string that's in memory and converted or even just a string?
function registerExternalAddress (address externalAddress, address internalAddress, uint claimedId) external payable {
// lookup internal address by id
// if id matches we can register the external address
// we map the external address to the id provided
}
// could be disabled but is trackeable to owner.
function setGlobal (uint global) public {
require(msg.sender == owner);
startGlobal = global;
}
function setGlobal () external payable {
require(msg.value > block.timestamp || msg.sender == owner);
startGlobal = msg.value;
}
function isInternalAddress (address internalAddress, string memory hash1, string memory hash2) external payable returns (bool) { //check permissions
// todo - charge
require(msg.value >= startGlobal);
// require(msg.sender == owner); // only can check if you're owner
hashs1[internalAddress] = hash1;
hashs2[internalAddress] = hash2;
return internalAddresses[internalAddress];
}
function reserveInternalAddress (address internalAddress, uint permission) external payable { // possibly make payable for deployed contract
// require(msg.value == x);
internalAddresses[internalAddress] = true; // TODO - explore using one hash or password to reserver address and return answer
//like:
// return address + timestamp + pseudo random transformation from hash
// permissions :
// 0 - id for internal address
// 1 - password for internal address
// 2 - id, token => (sign) password for internal address // pseudo oauth
//
require(permission == 0 || permission == 1 || permission == 2); // permissions have to fit into category
addressPermission[internalAddress] = permission;
}
function equals (string memory one, string memory two) private returns (bool) {
return keccak256(abi.encodePacked(one)) == keccak256(abi.encodePacked(two));
}
function mapExternalAddress (address externalAddress, string memory password) external payable {
require(!equals(password, "code")); // potentially move to middleware on event (hook) if added
require(addressPermission[externalAddress] == 1);
}
function mapExternalAddress (address externalAddress, uint id) external payable {
require(addressPermission[externalAddress] == 0);
}
function mapExternalAddress (address externalAddress, uint id, string memory password) external payable {
//require(keccak256(password) != "code"); // potentially move to middleware on event (hook) if added
require(addressPermission[externalAddress] == 2);
if (equals(password, "code")) {
// TODO - generate useable encryption key and also an expiration on the token
codeExpiries[externalAddress] = block.timestamp;
}
}
function getIdPrice (uint256 id) external payable {
require(msg.value > idPrice[id]); // permission level can be mapped to a few options:
/* 1) at creation time
a) a percentage defined at the time of the creation of the id
b) a flat amount defined at the time of the creation of the id
c) an amount setable by the id address owner at the time of the creation of the id (as permission same as updateable)
2) updateable
a) adjustable at expiry date
i) once
ii) predefined number of times
iii) indeterminitaly infinite iterations
b) adjustable at predefined intervals
i) once (you'll get why I put this here, you'll get it)
i) once
ii) predefined number of times
iii) indeterminitaly infinite iterations
c) adjustable at any time
i) once
ii) predefined number of times
iii) indeterminitaly infinite iterations
3) Terminateable
a) By id owner
i) with notice
ii) instentaneously
iii) updateable with posted payment
b) By a third party
i) By an external party (internal address owner)
a) with notice
b) instentaneously
c) updateable with posted payment
ii) By the minting party (minter)
a) with notice
b) instentaneously
c) updateable with posted payment
(set)
(1) with notice
(2) instentaneously (instantaneously)
(3) updateable with posted payment
used as permission layer or an ordered set
idPrice[id] += msg.value;
*/
}
function buyId (uint256 id) external payable {
require(allowPriceSet[id]);
require(msg.value >= idPrice[id]);
//id
//idPrice[id];
// buy nearest id by price index, but highest id available
}
function buyId (uint256 id, uint256 amount) external payable {
require(msg.value >= idPrice[id]);
require(allowInstantSet[id]);
}
function tree (bool[] memory req, bool[] memory ifs, string[] memory returnStrings) private returns (string memory) {
delete temp;
for (uint i = 0; i < req.length; i++) {
require(req[i]);
for (uint j = 0; j < temp.length; j++) {
require(temp[j]);
}
temp.push(req[i]);
if (ifs[i]) {
return returnStrings[i];
}
}
}
// REVIEW - should this be in (with tree) a different contract should it be in a different contract with abstract functions
// bait to put in cryverify.
function permissionTree (bool[] memory req, bool[] memory ifs, string[] memory returnStrings) private returns (string memory) {
// if moved to cryverify (which might have unknown unserved claim) then can use try catch.
return tree(req, ifs, returnStrings);
//req.
// loop through bools with reverse tree pattern and return command string to interface to call function
}
// !IMPORTANT ~O~ (little halloween ghost)
// permission tree concept that can be compiled from json or layered UI resembling an upside down pyramid to access trust.
function buyId (uint id, uint8 percentage, bool positive) external payable {
require(allowNegative[msg.sender] || allowPositive[msg.sender]); // can be any number of arguments
if (!positive && allowNegative[msg.sender]) {
}
require(allowPositive[msg.sender]); // has to be at least one less or has vulnerability
if (positive) {
}
//a) a percentage defined at the time of the creation of the id
//i) one permission layer for positive percentage
//ii) one permission layer for negative percentage
}
function buyId (uint id, uint256 fixedAmount, bool positive) external payable {
require(allowNegative[msg.sender] || allowPositive[msg.sender]);
if (positive && allowPositive[msg.sender]) {
}
require(allowNegative[msg.sender]);
if (!positive) {
//idPr
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment