layer-3 / clearsync Goto Github PK
View Code? Open in Web Editor NEWClearing system for Inter-Exchange and others trading firms.
Home Page: https://www.yellow.org
License: GNU General Public License v3.0
Clearing system for Inter-Exchange and others trading firms.
Home Page: https://www.yellow.org
License: GNU General Public License v3.0
websocket URL must start with ws:// or wss:// (got '')
- exampleGenerating a session key in the Ethereum ecosystem typically involves creating a new Ethereum account (which inherently means generating a new public-private key pair) that is authorized to act on behalf of the main account under specific conditions. This new account acts as the session key. Ethereum itself doesn't have a built-in "session key" type or interface per se, but you can implement this concept through smart contract logic.
Here's a simplified approach to generating and using a session key:
ethers.js
or web3.js
. This new account will be your session key.Here’s a basic example using Solidity:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract SessionKeyManager {
address public mainAccount;
address public sessionKey;
uint256 public sessionKeyExpiration;
constructor() {
mainAccount = msg.sender;
}
// Set a new session key with an expiration time
function setSessionKey(address _sessionKey, uint256 duration) external {
require(msg.sender == mainAccount, "Only main account can set session key");
sessionKey = _sessionKey;
sessionKeyExpiration = block.timestamp + duration;
}
// Function that checks if the caller is the valid session key
modifier onlySessionKey() {
require(msg.sender == sessionKey, "Caller is not the session key");
require(block.timestamp <= sessionKeyExpiration, "Session key expired");
_;
}
// Example of a restricted function
function doSomethingRestricted() external onlySessionKey {
// Restricted logic here
}
// Function to clear the session key
function clearSessionKey() external {
require(msg.sender == mainAccount || msg.sender == sessionKey, "Unauthorized");
sessionKey = address(0);
sessionKeyExpiration = 0;
}
}
In this contract:
mainAccount
can set a sessionKey
with a specific expiration time.doSomethingRestricted
function can only be called by the sessionKey
and only if it hasn't expired.sessionKey
can be cleared by either the mainAccount
or the sessionKey
itself.Using Web3.js, you can generate a new account like this:
const Web3 = require('web3');
const web3 = new Web3(Web3.givenProvider || 'ws://localhost:8545');
const sessionKeyAccount = web3.eth.accounts.create();
console.log("Session Key Address:", sessionKeyAccount.address);
console.log("Session Key Private Key:", sessionKeyAccount.privateKey);
This implementation is quite basic. Depending on your specific requirements, you might need a more sophisticated system with additional checks, balances, and features.
ToDo:
Read the docs, remove outdated parts and add the new vision
It was tested via testnet.yellow.org, but will there be a different test network in the future?
peers.json
should contain domains of clearports that we are going to deploy on this network, ports depend on the infrastructure; addresses should be got from private keys generated for each node; names can be chosen freelyblockchain.json
should include correct addresses of all deployed contracts, blockchainRPC
should point to WS endpoint of network nodeassets.json
should include all assets that can be accepted by a clearport and listed in the yellow walletmarkets.json
all markets supported by Kayen (currently only USD quotes are supported)Difficulty of one node deployment depend on the infrastructure and whether it has already PostgreSQL and InfluxDB instances that can be used.
A participant may not have assets on hand to settle a trade, therefore a more elaborate red zone reaction should be thought of.
By @dpatsora about YIP 0006 - Margin Zones.
fix FIXME and do TODO
Both Yellow and Red zones mentioned that trades are not allowed, but I think it is about orders.
By @pkucherenk0 in #124 .
Problem to solve: It was agreed that the Alpa will be released on the Canary (network placeholder) main-net network. This should make Alpha more influential for testers, the team, and the community. Allowing us to transit to the main-net more easily, and find the issues and abuses prior to the public release. This will create adoption metrics for VC
Acceptance Criteria:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.