Functions

Descriptions of NEOPIN Connect functions

Type
Descriptions

Method for connecting with the NEOPIN Wallet, and the URL is returned when the connection is made.

ex) ConnectManager.shared.connect()

Method for disconnecting from the NEOPIN Wallet. Disconnect is recommended in the following cases.

  • When the app is terminated or forcibly terminated. (AppDelegate.applicationWillTerminate)

  • When the transaction with NEOPIN Wallet is finished.

  • When a certain time passes after connecting to NEOPIN Wallet.

ex) ConnectManager.shared.disconnect()

Method for obtaining the address of the NEOPIN Wallet.

Addresses can be imported only when Wallet is connected.

ex) ConnectManager.shared.getMyAccount()

Among the methods for communicating with the NEOPIN Wallet, this is the most important method. After sending a Transaction to the wallet, you must give a response value from the Wallet to receive it as a Response.

  • When creating a Transaction in this method, be sure to check the variable values (from, to, data, gas, gasPrice, value, nonce, type, accessList, chainId, maxPriorityFeePerGas, maxFeePerGas).

  • When creating a Client.Transaction object for SendTransaction, specify the ChainID of the target network. (*Required)

  • Data, one of the values of Transaction, must be entered as encodedData that complies with ERC-20 “Transfer”. Please refer to the example.

Signs a transaction that can be submitted to the network

The sign method calculates an Ethereum specific signature with:sign(keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))).

Connect

Method for connecting with the NEOPIN Wallet, and the URL is returned when the connection is made.

The code block below is a code that requests connection to the NEOPIN Wallet through ConnectManager and opens the NEOPIN Wallet through the obtained URL.

You must request a connection and approve it in the NEOPIN Wallet to connect to the Wallet.

guard let connectionURL = ConnectManager.shared.connect() else {
        print("Connection Fail")
        return
}
        
let deepLinkURL = "examplewallet\(connectionURL)"
guard let url = URL(string: deepLinkURL) else { return }
UIApplication.shared.open(url, options: [:], completionHandler: nil)

Close

Method for disconnecting from the NEOPIN Wallet.

Disconnect is recommended in the following cases.

  • When the app is terminated (AppDelegate.applicationWillTerminate)

  • When the transaction with NEOPIN Wallet is finished

  • When connected to NEOPIN Wallet, but a certain amount of time has elapsed

ex) ConnectManager.shared.disconnect()

GetAccount

Method for obtaining the address of the NEOPIN Wallet.

Addresses can be imported only when Wallet is connected.

ex) ConnectManager.shared.getMyAccount()

SendTransaction

Method for communicating with the NEOPIN Wallet.

The following procedure is required to use NEOPIN Connect_sendTransaction in DApp.

  • Create Transaction encodedData compliant with ERC-20.

    • Data, one of the values of Transaction, must be entered as encodedData that complies with ERC-20 “Transfer”. Please refer to the example.

    • Create Transaction by filling in the remaining values.

      • When creating a Transaction in this method, be sure to check the variable values. In this project, an arbitrary value is set. (from, to, data, gas, gasPrice, value, nonce, type, accessList, chainId, maxPriorityFeePerGas, maxFeePerGas).

    • Transfer to the NEOPIN Wallet.

      • Please create a Transaction object after checking Address(From, To).

      • After sending the Transaction to the Wallet, you can receive Response only when the wallet gives a response value.

SignTransaction

  • Transfer to the NEOPIN Wallet.

    • Please create a Transaction object after checking Address(From, To).

    • After sending the Transaction to the Wallet, you can receive Response only when the wallet gives a response value.

  • Signs a transaction that can be submitted to the network

PersonalSign

  • The sign method calculates an Ethereum specific signature with:sign(keccack256("\\x19Ethereum Signed Message:\\n" + len(message) + message))).

  • By adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.

  • Note See ecRecover to verify the signature.

Last updated