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

Use custom JSONRPCmethod and Units #148

Closed
iosbowhead opened this issue Apr 2, 2019 · 2 comments
Closed

Use custom JSONRPCmethod and Units #148

iosbowhead opened this issue Apr 2, 2019 · 2 comments

Comments

@iosbowhead
Copy link

Hi, we created our own Ethereum fork, is there anyway to configure this library for using our own RPC methods and our own Units?

@BaldyAsh
Copy link
Collaborator

BaldyAsh commented Apr 2, 2019

@iosbowhead hi!
Currently RPC methods aren't customisable. It is the nice feature and I'll make it in next releases.
But you can use your own network in two ways:

// Directly creating provider
let url = URL(string: "https://yourendpoint.net/")! // endpoint
let provider = Web3HttpProvider(url, keystoreManager: keystoreManager)! // here you can also add keystore manager if you want
let web = web3(provider: provider) // create web3 instance
// Alternatively you can create web3 instance
let web = Web3.new(url) // but here you can't specify keystore manager
web3.addKeystoreManager(keystoreManager)

Regarding units - use Web3.Utils.formatToPrecision

let value = Web3.Utils.formatToPrecision(<bigNumber: BigInt>, numberDecimals: <Int>, formattingDecimals: <Int>, decimalSeparator: <String>, fallbackToScientific: <Bool>)

@iosbowhead
Copy link
Author

Thank you for your answer

@BaldyAsh BaldyAsh closed this as completed Apr 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants