projectchicago / gastoken Goto Github PK
View Code? Open in Web Editor NEW⛽ Tokenize gas on Ethereum with GasToken ⛽
Home Page: https://gastoken.io
⛽ Tokenize gas on Ethereum with GasToken ⛽
Home Page: https://gastoken.io
Hi,
wanted to know whether this works on ROPSTEN, as I am trying to integrate GST2 into my contract and it never works. I made a really simple contract where I call a function which does the mint, this worked as expected. I got x tokens minted. But, then ran a function FreeNCallX(), where i added some logic over going over a fixed sized array and doing some maths. But this function doesnt seem to work at all.
I implemented the GST2.sol contract on ROPSTEN and then started using it.
So i wanted to know does this even work and if, yes, how can I get it to work on ROPSTEN.
So I get that this refunds you gas when you free your tokens. But to benefit, do you need to be trying to have another tx confirmed at the same time? When and where does the benefit of the refunded gas actually occur?
Are there any plans to upgrade the compiler from 0.4 to 0.5? Do any of the changes improve gas costs?
So to clarify, I have GTS2 coins in an ETC wallet. (This prevents me from swapping them in Uniswap).
I ultimately want to sell these coins and transfer them into a fiat currency or other coins (ETH).
When I first bought the gas, I didn't consider it as a long-term hold, but I was wrong.
The Saturn network is no longer working, and in my MEW, I can only trade on the ETH network.
I wanted to get rid of these coins last month before they dropped 50% 800, 400 AUD (now 200). I couldn't get the Saturn network exchange to load.
On blockscout https://blockscout.com/etc/mainnet/address/0x0000000000b3F879cb30FE243b4Dfee438691c04/transactions
I am not a blockchain developer.
From what I understand, this process can be complicated; However, if these coins are forever lost, I would like to know.
If not, for the love of Pete, someone please explain how I can get them out from my ETC wallet and into something fungible.
Could a portable token bridge be made between the two networks such as Metronome's bridge?
In the meantime, I will wait for the Saturn Network to come out of the shadows.
gas
Hi all, can anyone tell me how to use the token with metamask?
Just wanted to say this is a cute project. I have been studying and wanted to share my notes.
Current contract call costs 22 gas.
https://github.com/projectchicago/gastoken/blob/master/contract/GST2_ETH.sol#L106-L114
Gas | Set | Inst |
---|---|---|
3 | VERYLOW | PUSH15 0xb3f879cb30fe243b4dfee438691c04 |
2 | BASE | CALLER |
3 | VERYLOW | XOR |
2 | BASE | PC |
10 | HIGH | JUMPI |
2 | BASE | CALLER |
— | — | SELFDESTRUCT |
Proposed update requires 19 gas.
Gas | Set | Inst |
---|---|---|
3 | VERYLOW | PUSH15 0xb3f879cb30fe243b4dfee438691cXX |
2 | BASE | CALLER |
3 | VERYLOW | XOR |
8 | MID | JUMP |
1 | JUMPDEST | JUMPDEST |
2 | BASE | CALLER |
— | — | SELFDESTRUCT |
With this new technique, the comment on the homepage can be updated:
The address of our GST2 GasToken, 0x0000000000b3F879cb30FE243b4Dfee438691c04, is hardcoded. Note that this address is very short (only 15 non-zero bytes instead of 20). We generated our GasToken contract at such an address on purpose, so as to save some gas when creating contracts. The above child contract uses 22 bytes of code, and thus costs roughly 32000 + 22 * 200 = 36400 gas to create (the additional overhead of calling mint is only about 150 gas). If we could make use of address 0x0 for GasToken, we could save an extra 3000 gas or so for every created contract!
Don't worry about the 0x0 address. You want the 0xPC address. Then you can additionally save the PUSH15
and XOR
operations.
This proposed update also affects the efficiency ratio and other parts of the web page.
I'm working on a smart contract that I'm expecting to use a lot of gas and gastoken looks like one way for me to reduce costs.
The calculator on https://gastoken.io/ is very helpful for knowing how much gastoken to free, but is there a similar calculation for optimizing the minting process?
It looks like https://github.com/projectchicago/gastoken/blob/master/miner/example_constant_price.py#L35 mints 26 (0x1a) tokens. Was there any particular reason this number was picked?
Can you also explain what gas_delta
is doing in the example code?
Is there also a gastoken contract deployed on polygon (matic network)? Or is there no gas refund mechanism in the polygon protocol, i.e. gastoken not possible there?
It seems https://github.com/ethereum/pyethereum is deprecated.
Could you please provide the updated requirements file?
Would a PR be welcome that adds setup instructions to the miners README and adds comments to the code? I'd be happy to do it. I think I have it working on a local ganache node
In normal eth transaction when the tx fails, miner gets rewarded of some gas due to its work.
Does it happen the same here as well?
As you asked:
If you know of even "rarer" addresses in Ethereum (that is, with an over 5 byte recognizable pattern), let us know!
Here is the project: https://github.com/johguse/profanity
As I may see author donation address is 5-byte length:
0x000dead000ae1c8e8ac27103e4ff65f42a4e9203
when calling free in GST2.sol, it will call selfdestruct and send all asset to msg.sender, why? I think it should be send to tx.origin?
Estimated gas: 526
function mk_contract_address(uint _nonce) private view returns(address) {
if(_nonce == 0x00) return address(uint256(keccak256(abi.encodePacked(byte(0xd6), byte(0x94), address(this), byte(0x80)))));
if(_nonce <= 0x7f) return address(uint256(keccak256(abi.encodePacked(byte(0xd6), byte(0x94), address(this), uint8(_nonce)))));
if(_nonce <= 0xff) return address(uint256(keccak256(abi.encodePacked(byte(0xd7), byte(0x94), address(this), byte(0x81), uint8(_nonce)))));
if(_nonce <= 0xffff) return address(uint256(keccak256(abi.encodePacked(byte(0xd8), byte(0x94), address(this), byte(0x82), uint16(_nonce)))));
if(_nonce <= 0xffffff) return address(uint256(keccak256(abi.encodePacked(byte(0xd9), byte(0x94), address(this), byte(0x83), uint24(_nonce)))));
return address(uint256(keccak256(abi.encodePacked(byte(0xda), byte(0x94), address(this), byte(0x84), uint32(_nonce))))); // more than 2^32 nonces not realistic
}
I'm working on democracy smart contracts. The proposal system have it's own contract, and once thefinal result is read by democracy, it can be discarded.
The amount of storage inside of this contract can be huge, because tabulation requires saving several information in state.
I see it could be possible for the contract enter in a "storage destruct" state, where the "free" could contain the pointer to delete (depending on how data is saved)
The contract could have some special interface for saving and reading data, probably as a key-value storage. When a proposal is in this stage, it could be used as gas token.
There is also the case for MiniMeToken, which have a storage of all history of token. This contract could allow very old (more then one year) data being cleared up by other contracts with expansive calls.
This might be related for the gas rent that ethereum probably should support in future https://ethresear.ch/t/a-simple-and-principled-way-to-compute-rent-fees/1455 and might be a path forward for Gas Token to exists in such scenario.
From GST1.sol
// Spec: Allow `spender` to withdraw from your account, multiple times, up
// to the `value` amount. If this function is called again it overwrites the
// current allowance with `value`.
function approve(address spender, uint256 value) public returns (bool success) {
address owner = msg.sender;
if (value != 0 && s_allowances[owner][spender] != 0) {
return false;
}
s_allowances[owner][spender] = value;
Approval(owner, spender, value);
return true;
}
From comment:
If this function is called again it overwrites the current allowance with
value
.
This is not true, if this function is called second time(or multiple time) it will not overwrite previus allowance unless it is 0.
Correct implementation would be:
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
s_allowances[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
Is there a reason why these are not deployed in the Binance Smart Chain? Would they also work there?
Also, where could I check the gas cost (and refunds) for each opcode in the BSC EVM?
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.