# Execute SendCoin/Contract

{% hint style="warning" %}
Send coins and executing smart contracts is possible from wallet security level 2.

To learn about wallet security, read [Wallet Security Level](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/ios/etc).
{% endhint %}

## Steps

1. [Search Gas Fee](#search-gas-fee)
2. [Search Ticket information](#search-ticket-information)
3. [Create Ticket](#create-ticket)
4. [Transfer Ticket](#transfer-ticket)
5. [Check Transaction Result  ](#check-transaction-result)

```swift
// 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.

```swift
let gas: GasPriceInfo = try await fncyWallet.getGasPrice(chainId: 3)
```

#### See Also&#x20;

[getGasPrice](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/methods#func-getgasprice)

[GasPriceInfo](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/domain#gaspriceinfo)&#x20;

## 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&#x20;

[estimateTicket](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/methods#func-estimateticket)

[FncyTicket](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/domain#fncyticket)

[TicketType](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/etc#tickettype)

### Transfer Coin

```swift
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)

```swift
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

```swift
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).**

{% hint style="info" %}
If the ticket creation fails, the TicketUUID does not returned.
{% endhint %}

#### See Also&#x20;

[makeTicket](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/methods#func-maketicket)

[TicketType](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/etc#tickettype)

### Transfer Coin

```swift
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)

```swift
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

<pre class="language-swift"><code class="lang-swift"><strong>let ticketUUID: String = try await fncyWallet.makeTicket(
</strong>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
)
</code></pre>

## 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.](#create-ticket)

```swift
let ticket: FncyTicket = try await fncyWallet.getTicketInfo(ticketUuid: "ticketUUID")
```

#### See Also

[getTicketInfo](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/methods#func-getticketinfo)

[FncyTicket](https://docs.fncy.world/fncy-2.0.2-eng/for-developers/wallet/sdk/domain#fncyticket)

## Transfer Ticket

{% hint style="info" %}
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.
{% endhint %}

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.](#create-ticket)

```swift
let txId: String = try await fncyWallet.sendTicket(
ticketUuid: "ticketUuid", // Ticket UUID
pinNumber: "000000" // Wallet Password
)
```

##

## Check Transaction Result

Search the returned txId in [FncyScan](https://fncyscan-testnet.fncy.world/)

```swift
let txId = try await fncyWallet.sendTicket(ticketUuid: "ticketUuid"
                                           pinNumber: "000000")                                                                 
print(txId)
// 0xc19f68e548c2ed933291aa4cbc9748b4d2b0de4bf1a5516f0b74579fb8e13b54
// FncyScan(Testnet): https://fncyscan-testnet.fncy.world/tx/0xc19f68e548c2ed933291aa4cbc9748b4d2b0de4bf1a5516f0b74579fb8e13b54

```
