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

ENS Functionality #56

Closed
barrasso opened this issue Oct 2, 2018 · 8 comments
Closed

ENS Functionality #56

barrasso opened this issue Oct 2, 2018 · 8 comments

Comments

@barrasso
Copy link
Contributor

barrasso commented Oct 2, 2018

Hey all, I am trying to build support for ENS into one of my mobile apps, (the ENS wallet from ETHBerlin), and I am having some trouble understanding how to get this done effectively.

I am attempting to interact with the Ropsten ENS contracts. Do I need to use the json ABI for the registrar in order to use it? Maybe it would be helpful to create a series of ENS handler classes like those found here: https://github.com/argentlabs/web3.swift/tree/master/web3swift/src/ENS

In the meantime, it would be super helpful if anyone could provide a guide or some examples on how to do this with the existing library functions. Thanks.

@shamatar
Copy link
Contributor

shamatar commented Oct 2, 2018 via email

@barrasso
Copy link
Contributor Author

barrasso commented Oct 2, 2018

Both @shamatar

@shamatar
Copy link
Contributor

shamatar commented Oct 2, 2018 via email

@barrasso
Copy link
Contributor Author

barrasso commented Oct 2, 2018

Ok awesome. I'd love to see that ENS resolver code. Also, I'd appreciate some examples in accessing arbitrary contracts-- maybe specifically on placing a bid or viewing open ENS auctions.

@shamatar
Copy link
Contributor

shamatar commented Oct 4, 2018

Initial functionality is now in 1.1.10, with something like

let ENS = ENS(web3: web)

There is a resolver there at least :)

@barrasso
Copy link
Contributor Author

barrasso commented Oct 4, 2018

This is great @shamatar -- I will try to contribute to this existing functionality as I dive deeper into the auction functions.

@barrasso
Copy link
Contributor Author

Having issues with getting a public key for domain on Mainnet:

        let web3 = Web3.InfuraMainnetWeb3()
        var ens = ENS(web3: web3)
        DispatchQueue.global().async {
            let result = ens.getPubkey(domain: "vitalik.eth")
            switch result {
            case .failure(let error):
                print(error.localizedDescription)
            case .success(let pubkey):
                print(pubkey)
            }
        }

Response:

Error: The operation couldn’t be completed. (web3swift.Web3Error error 7.)

Versus getting it on Ropsten:

        let web3 = Web3.InfuraRopstenWeb3()  // only thing that has changed
        var ens = ENS(web3: web3)
        DispatchQueue.global().async {
            let result = ens.getPubkey(domain: "vitalik.eth")
            switch result {
            case .failure(let error):
                print(error.localizedDescription)
            case .success(let pubkey):
                print(pubkey)
            }
        }

Response:

["y": <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>, "0": <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>, "x": <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>, "1": <00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000>]
PublicKey(x: "0x0000000000000000000000000000000000000000000000000000000000000000", y: "0x0000000000000000000000000000000000000000000000000000000000000000")

@barrasso
Copy link
Contributor Author

Got Mainnet working just using the standard arbitrary contract calls:

        // MAINNET
        let web3 = Web3.InfuraMainnetWeb3()
        let contractAddress = EthereumAddress("0x314159265dd8dbb310642f98f50c066173c1259b")!

        DispatchQueue.global().async {
            let gasPriceResult = web3.eth.getGasPrice()
            guard case .success(let gasPrice) = gasPriceResult else {return}
            print(gasPrice)
            var options = Web3Options.defaultOptions()
            options.gasPrice = gasPrice
            options.from = ks?.addresses?.first!
            let parameters = [NameHash.nameHash("vitalik.eth")] as [AnyObject]

            web3.addKeystoreManager(keystoreManager)
            let contract = web3.contract(Web3.Utils.ensRegistryABI, at: contractAddress, abiVersion: 2)!
            let intermediate = contract.method("owner", parameters:parameters,  options: options)
            DispatchQueue.global().async {
                guard let res = intermediate?.call(options: options) else {return}
                switch res {
                case .success(let res):
                    print("successful: \(res)")
                case .failure(let error):
                    print(error)
                }
            }
        }

Response:

successful: ["0": web3swift.EthereumAddress(_address: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", type: web3swift.EthereumAddress.AddressType.normal)]

@shamatar shamatar closed this as completed Nov 3, 2018
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