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

This request is not supported because your node is running with state pruning. Run with --pruning=archive. #274

Closed
jayarajb1116 opened this issue Sep 15, 2020 · 5 comments

Comments

@jayarajb1116
Copy link

I'm using kovan infura.

let endpoint = "https://kovan.infura.io/v3/XXXXXXXXXXXXX"
let web3Instance = web3(provider: Web3HttpProvider(URL(string: endpoint)!)!)

When I try to get balance of erc20 or make any transaction, I'm getting below issue.
nodeError(desc: "This request is not supported because your node is running with state pruning. Run with --pruning=archive.")

@skywinder
Copy link
Collaborator

Can't reproduce it. Can you please provide full code to test it?

@jayarajb1116
Copy link
Author

jayarajb1116 commented Oct 1, 2020

@skywinder
Please check the code below
I'm able to get ETH balance. but not other than that is working

import UIKit
import web3swift
import BigInt

class ViewController: UIViewController {

var keystoreManager: KeystoreManager!
var web3Instance: web3!

override func viewDidLoad() {
    super.viewDidLoad()
    
    // Import account
    let password = "xxxxxxxxx"
    let key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" // Some private key
    let formattedKey = key.trimmingCharacters(in: .whitespacesAndNewlines)
    let dataKey = Data.fromHex(formattedKey)!
    let keystore = try! EthereumKeystoreV3(privateKey: dataKey, password: password)!
    let name = "New Wallet"
    let keyData = try! JSONEncoder().encode(keystore.keystoreParams)
    let address = keystore.addresses!.first!.address
    let wallet = Wallet(address: address, data: keyData, name: name, isHD: false)
    
    let data = wallet.data
    
    if wallet.isHD {
        let keystore = BIP32Keystore(data)!
        keystoreManager = KeystoreManager([keystore])
    } else {
        let keystore = EthereumKeystoreV3(data)!
        keystoreManager = KeystoreManager([keystore])
    }
    
    let endpoint = "https://kovan.infura.io/v3/xxxxxxxxxxxxxxx"
    let web3Instance = web3(provider: Web3HttpProvider(URL(string: endpoint)!)!)
    
    web3Instance.addKeystoreManager(keystoreManager)
    
    // Get ETH balance
    let walletAddress = EthereumAddress(wallet.address)! // Address which balance we want to know
    let balanceResult = try! web3Instance.eth.getBalance(address: walletAddress)
    let balanceString = Web3.Utils.formatToEthereumUnits(balanceResult, toUnits: .eth, decimals: 3)!
    print("ETH BALANCE : ", balanceString)
    
    // Get token balance
    let exploredAddress = EthereumAddress(wallet.address)! // Address which balance we want to know. Here we used same wallet address
    let erc20ContractAddress = EthereumAddress("0xXXXXXXXXXXXXXXXXXXX")!
    let contract = web3Instance.contract(Web3.Utils.erc20ABI, at: erc20ContractAddress, abiVersion: 2)!
    var options = TransactionOptions.defaultOptions
    options.from = walletAddress
    options.gasPrice = .automatic
    options.gasLimit = .automatic
    let method = "balanceOf"
    let tx = contract.read(
        method,
        parameters: [exploredAddress] as [AnyObject],
        extraData: Data(),
        transactionOptions: options)!
    do {
        let tokenBalance = try! tx.call()
        let balanceBigUInt = tokenBalance["0"] as! BigUInt
        let erc20balanceString = Web3.Utils.formatToEthereumUnits(balanceResult, toUnits: .eth, decimals: 3)!
    }catch let error{
        print(error)
    }
}

}

@jayarajb1116 jayarajb1116 changed the title his request is not supported because your node is running with state pruning. Run with --pruning=archive. This request is not supported because your node is running with state pruning. Run with --pruning=archive. Oct 5, 2020
@jdoshi1
Copy link

jdoshi1 commented Oct 6, 2020

@skywinder Are you able to reproduce this issue? We are using Infura endpoint, do we need to enable archived data access in Infura?
We tested with few other Ether+ios kits and the same Infura API, but we are not seeing this issue.

Appreciate you looking into it. Thanks.

@skywinder
Copy link
Collaborator

skywinder commented Oct 6, 2020

@skywinder Are you able to reproduce this issue? We are using Infura endpoint, do we need to enable archived data access in Infura?

We tested with few other Ether+ios kits and the same Infura API, but we are not seeing this issue.

Appreciate you looking into it. Thanks.

No. Can't reproduce. Looks like it was error on the Infura side. It was already discussed in other issues in the repo.

Please have a look at #239 (comment)

@skywinder
Copy link
Collaborator

close in favor of #239

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

3 participants