Search code examples
iosblockchainaionpokt

Got an "configurationError" when sending a transaction in Xcode


When I try to send a transaction on the Aion network, I keep getting the "configurationError". I am using Xcode to create my IOS dApp.

The code i have to send a transaction is:

@IBAction func sendTxButton(_ sender: Any) {

    //deleted my address and pk

    let address = "0x0" 
    let privateKey = "0x0"


    let nonce = BigInt.init(3)
    let to =  "0xa0d969df9232b45239b577c3790887081b5a22ffd5a46a8d82584ee560485624"
    let value =  BigInt.init(10000000)
    let nrgPrice = BigInt.init(10000000000)
    let nrg = BigInt.init(21000)

    var txParams = [AnyHashable: Any]()
    txParams["nonce"] = HexStringUtil.prependZeroX(hex: nonce.toString(radix: 16))
    txParams["to"] = to
    txParams["data"] = ""
    txParams["value"] = HexStringUtil.prependZeroX(hex: value.toString(radix: 16))
    txParams["nrgPrice"] = HexStringUtil.prependZeroX(hex: nrgPrice.toString(radix: 16))
    txParams["nrg"] = HexStringUtil.prependZeroX(hex: nrg.toString(radix: 16))

    do {


        let importWallet = try PocketAion.importWallet(privateKey: privateKey, subnetwork: "32", address: address, data: nil)

        try PocketAion.eth.sendTransaction(wallet: importWallet, nonce: nonce, to: to, data: "", value: value, nrgPrice: nrgPrice, nrg: nrg, handler: { (result, error) in
            if error != nil {
                print(error!)
                return
            } else {
                print("the hash:", result!)
            }

        })

    } catch{
        print(error)
    }

}

I have met all of the requirements on sending a transaction, but cant figure out what is wrong.(this is for sending test tokens on the Aion test net "32").


Solution

  • check your AppDelegates class. make sure you have added "configuration" and point it to the right URL and under the application function you make sure you have the configuration is set to "self".

    
    class AppDelegate: UIResponder, UIApplicationDelegate, Configuration {
    
    
    
        public var nodeURL: URL{
    
            get {
    
                return URL.init(string: "https://aion.pokt.network")!
    
            }
    
        }
    
    
    
        var window: UIWindow?
    
    
    
    
    
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
            // Override point for customization after application launch.
    
    
    
           PocketAion.shared.setConfiguration(config: self)
    
            return true
    
        }