Send coins and executing smart contracts is possible from wallet security level 2.
To learn about wallet security, read Wallet Security Level.
Steps
// Sample Usage
let wallet: FncyWallet = let wallet: FncyWallet = try await fncyWallet.getWallet()
// 1. Gas Price Search
let gas: GasPriceInfo = try await self.fncyWallet.getGasPrice(chainId: 3)
// 2. Ticket Search
let estimateResult:
FncyTicket = try await fncyWallet.estimateTicket(wid: wallet.wid,
chainId: 3,
signatureType: .assetTransfer,
toAddress: wallet.walletAddress,
assetId: 6)
// 3. Ticket 생성
let ticketUUID = try await fncyWallet.makeTicket(wid: wallet.wid,
chainId: 3,
signatureType: .assetTransfer,
toAddress: wallet.walletAddress,
transferVal: "100000",
txGasPrice: gasPriceInfo.middleGasPrice.description,
assetId: 6)
print("ticketUUID : ", ticketUUID)
// 4. Ticket Trasnfer
let txId = try await fncyWallet.sendTicket(ticketUuid: ticketUUID,
pinNumber: "111111")
// 5. Transaction Result check
print("txID : ", txId)
//txID : 0xc19f68e548c2ed933291aa4cbc9748b4d2b0de4bf1a5516f0b74579fb8e13b54
Search Gas Fee
Gets the current network fee (gas fee) information for the network (blockchain) corresponding to the ChainID.
let gas: GasPriceInfo = try await fncyWallet.getGasPrice(chainId: 3)
See Also
getGasPrice
GasPriceInfo
Search Ticket Information
Before creating a ticket, it checks for transferability, nonce, GasLimit, etc.
Depending on the type of asset you're sending, or whether you're sending via WalletConnect, you'll need to select the correct ticket type.
AssetTransfer : CoinTransfer
SmartContract : TokenTransfer & Contract Execution
WalletConnect : Used when connecting to WalletConnect
See Also
estimateTicket
FncyTicket
TicketType
Transfer Coin
let ticketData: FncyTicket = try await fncyWallet.estimateTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.assetTransfer,
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "1000000000000000000", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil //For ETH Transfers
)
Transfer Token(Contract Execution)
let ticketData: FncyTicket = try await fncyWallet.estimateTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.smartContract, //
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "0", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
contractAddress: "0x1234...", //Contract Address
txInput: "0x123456....", //Data
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil //For ETH Transfers
)
WalletConnect
let ticketData: FncyTicket = try await fncyWallet.estimateTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.walletConnect, //
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "1000000000000000000", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
contractAddress: "0x1234...", //Contract Address
txInput: "0x123456....", //Data
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil //For ETH Transfers
)
Create Ticket
Registers a ticket (transaction information) with the server to send to the network, and recieves the ticket's TicketUUID (TicketUUID).
If the ticket creation fails, the TicketUUID does not returned.
See Also
makeTicket
TicketType
Transfer Coin
let ticketUUID: String = try await fncyWallet.makeTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.assetTransfer,
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "1000000000000000000", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil, //For ETH Transfers
txGasLimit: 21000 // Gas Limit
)
Transfer Token(Contract Execution)
let ticketUUID: String = try await fncyWallet.makeTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.smartContract, //
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "0", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
contractAddress: "0x1234...", //Contract Address
txInput: "0x123456....", //Data
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil, //For ETH Transfers
txGasLimit: 21000 // Gas Limit
)
WalletConnect
let ticketUUID: String = try await fncyWallet.makeTicket(
wid: 10000, //Wallet ID
chainId: 3, // bsc: 1, eth: 2, fncy: 3
signatureType: TicketType.walletConnect, //
toAddress: "0x1234...", //Address to Receive Coins
transferVal: "1000000000000000000", //Quantity to Send (in wei)
txGasPrice: "10000000000", //Gas Price (in wei)
contractAddress: "0x1234...", //Contract Address
txInput: "0x123456....", //Data
assetId: 6, //Transfer Asset's Asset ID
maxPriorityPerGas: nil, //For ETH Transfers
maxFeePerGas: nil, //For ETH Transfers
txGasLimit: 21000 // Gas Limit
)
Check Ticket Information
You can use the issued ticket UUID to search information about that ticket.
To learn how to request a ticket UUID, read Create a ticket.
let ticket: FncyTicket = try await fncyWallet.getTicketInfo(ticketUuid: "ticketUUID")
See Also
getTicketInfo
FncyTicket
Transfer Ticket
Ticket transfer requests the actual execution of a transaction using the ticket information registered on the server.
If the ticket transfer is successful, the transaction history is permanently included in the blockchain and cannot be changed or canceled.
Passes the issued ticket UUID and wallet password to execute a transaction corresponding to the ticket.
To learn how to request a ticket UUID, read Create a ticket.
let txId: String = try await fncyWallet.sendTicket(
ticketUuid: "ticketUuid", // Ticket UUID
pinNumber: "000000" // Wallet Password
)
Check Transaction Result
Search the returned txId in FncyScan
let txId = try await fncyWallet.sendTicket(ticketUuid: "ticketUuid"
pinNumber: "000000")
print(txId)
// 0xc19f68e548c2ed933291aa4cbc9748b4d2b0de4bf1a5516f0b74579fb8e13b54
// FncyScan(Testnet): https://fncyscan-testnet.fncy.world/tx/0xc19f68e548c2ed933291aa4cbc9748b4d2b0de4bf1a5516f0b74579fb8e13b54