Code Monkey home page Code Monkey logo

gastoken's People

Contributors

ftramer avatar lorenzb avatar pdaian avatar shubhamtatvamasi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gastoken's Issues

Does this work on Ropsten?

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.

Update solidity to 0.5?

Are there any plans to upgrade the compiler from 0.4 to 0.5? Do any of the changes improve gas costs?

How do I transfer GST2 from one the ETC network to the ETH network.

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.

More efficient GST2 implementation

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.

Optimal amount to mint?

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?

A question in GSTTokenv2

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?

More optimized mk_contract_address function

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
}

Make a Storage Gas Token Contract that owner can transform in Gas Token once data is no longer needed

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.

Incorrect implementation of approve function

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;
  }

Deployment in BSC?

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.