This guide will walk you through how your Portal Wallets work with ERC20 tokens, how to interface with ERC20 Token Contracts, and how to use the Portal Provider to transfer ERC20 tokens.
view
keyword. This means that these functions can be invoked using eth_call
RPC method and do not change the state of the blockchain. This also means that calling these functions does not require gas.
view
keyword, which means they do change the state of the blockchain. This requires sending a signed transaction to the blockchain, along with gas, to update the global state. These functions are invoked using the eth_sendTransaction
RPC method.
tokenAddress
for UNI (0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984
).
Web3.swift
library allows you to easily interface with token contracts to build the appropriate transaction payload for an ERC20 transaction without needing to manually build eth_call
requests. We’ll be using it for this purpose in this example.
The following code demonstrates how to use the Web3.swift
library to access an instance of the UNI Contract and generating a basic send
transaction.