Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add override for gasPrice (to ethers-wallet) #12

Open
parliament718 opened this issue Dec 12, 2017 · 1 comment
Open

Add override for gasPrice (to ethers-wallet) #12

parliament718 opened this issue Dec 12, 2017 · 1 comment
Assignees

Comments

@parliament718
Copy link

Currently defaults to 35 Gwei. Suggested value is 25 Gwei as per this article from cryptokitties team https://medium.com/@CryptoKitties/cryptokitties-birthing-fees-increases-in-order-to-accommodate-demand-acc314fcadf5

Please make options object (or at least gas price) overridable in Manager.prototype.giveBirth()

@ricmoo
Copy link
Owner

ricmoo commented Dec 12, 2017

The gas price currently comes from the Ethereum network, but yes I should add the ability to override it for those wish to have finer grained control. Give me a day to think about the best way to support this in a more general way.

I think I will add a optional function to signers for getGasPrice(tx).

I would also like to add a feature where the gasPrice can be set to specific constants, in which case it will use the ethers gas oracle; for example "low" would use the current safe low value for the network. I still need to think more about this though, since it will greatly increase the traffic to my public API.

If you need something ASAP, for now, you can just create a custom signer, which will allow you to override this.

var ethers = require('ethers');
var meow = require('ethers-meow');

function CustomSigner(privateKey) {
    this.provider = ethers.providers.getDefaultProvider();

    var wallet = new ethers.Wallet(privateKey, this.provider);

    this.address = wallet.address;

    this.sendTransaction = function(tx) {
        tx.gasPrice = 25000000000;
        console.log(tx);
        return wallet.sendTransaction(tx);
    }
}

var customSigner = new CustomSigner('0x0123456789012345678901234567890123456789012345678901234567890123');

var manager = new meow.Manager(customSigner);

manager.giveBirth(1000);

@ricmoo ricmoo changed the title giveBirth() needs ability to override gas price. Add override for gasPrice Dec 12, 2017
@ricmoo ricmoo self-assigned this Dec 12, 2017
@ricmoo ricmoo changed the title Add override for gasPrice Add override for gasPrice to ethers-wallet Dec 12, 2017
@ricmoo ricmoo changed the title Add override for gasPrice to ethers-wallet Add override for gasPrice (to ethers-wallet) Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants