# 코인보내기/Contract 실행

### Steps

1. [가스비 조회](#undefined)
2. [티켓 정보 조회](#undefined-1)
3. [티켓 생성](#undefined-2)
4. [티켓 전송](#undefined-4)
5. Transaction 결과 확인 &#x20;

## 가스비 조회

체인ID에 해당하는 네트워크(블록체인)의 **현재 네트워크 사용료(가스비)** 정보를 가져옵니다.

<pre class="language-kotlin"><code class="lang-kotlin">val gas = fncyWallet.<a data-footnote-ref href="#user-content-fn-1">getGasPrice</a>(
    chainId = 3
)
</code></pre>

#### See Also

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

[FncyGasPrice](https://docs.fncy.world/fncy-2.0.2-kor/for-developers/wallet/sdk/domain#fncygasprice)

## 티켓 정보 조회

Ticket을 생성하기 전 전송 가능여부 및 nonce, gasLimit등을 확인한다.

Ticket의 전송은 아래 3가지 타입이 있다.

* AssetTransfer : Coin전송
* SmartContract : Token전송 및 Contract 실행
* WalletConnect : WalletConnect연결 시에 사용

#### See Also

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

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

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

### Coin 전송

```kotlin
val info = fncyWallet.estimateTicket(
    walletId = 10000L, //지갑 ID
    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.AssetTransfer, 
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "1000000000000000000".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice = "10000000000".toBigInteger(), //Gas Price (단위: wei)
    assetId = 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO // ETH전송일 경우 사용
)
```

### Token 전송(Contract 실행)

```kotlin
val info = fncyWallet.estimateTicket(
    walletId = 10000L, //지갑 ID
    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.SmartContract, //
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "0".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice = "10000000000".toBigInteger(), //Gas Price (단위: wei)
    contractAddress = "0x1234...", //Contract Address
    txInput = "0x123456....", //Data
    assetId = 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO // ETH전송일 경우 사용
)
```

### WalletConnect

```kotlin
val info = fncyWallet.estimateTicket(
    walletId = 10000L, //지갑 ID
    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.WalletConnect, //
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "1000000000000000000".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice: "10000000000".toBigInteger(), //Gas Price (단위: wei)
    contractAddress: "0x1234...", //Contract Address
    txInput: "0x123456....", //Data
    assetId: 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO // ETH전송일 경우 사용
)
```

## 티켓 생성

네트워크에 전송할 티켓(트랜잭션 정보)을 서버에 등록하고, 해당 티켓의 UUID 정보를 가져옵니다.

#### See Also

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

[FncyTicketResult](https://docs.fncy.world/fncy-2.0.2-kor/for-developers/wallet/sdk/domain#fncyticketresult)

### Coin 전송

```kotlin
val info = fncyWallet.makeTicket(
    walletId = 10000L, //지갑 ID
    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.AssetTransfer, 
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "1000000000000000000".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice = "10000000000".toBigInteger(), //Gas Price (단위: wei)
    assetId = 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO, // ETH전송일 경우 사용
    txGasLimit = "21000".toBigInteger() // Gas Limit
)
```

### Token 전송(Contract 실행)

<pre class="language-kotlin"><code class="lang-kotlin">val info = fncyWallet.makeTicket(
<strong>    walletId = 10000L, //지갑 ID
</strong>    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.SmartContract, 
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "1000000000000000000".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice = "10000000000".toBigInteger(), //Gas Price (단위: wei)
    contractAddress: "0x1234...", //Contract Address
    txInput: "0x123456....", //Data
    assetId = 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO, // ETH전송일 경우 사용
    txGasLimit = "21000".toBigInteger() // Gas Limit
)
</code></pre>

### WalletConnect

<pre class="language-kotlin"><code class="lang-kotlin"><strong>val info = fncyWallet.makeTicket(
</strong>    walletId = 10000L, //지갑 ID
    chainId = 3L, // bsc: 1, eth: 2, fncy: 3
    signatureType = TicketType.WalletConnect, 
    toAddress = "0x1234...", //코인을 받을 주소
    transferVal = "1000000000000000000".toBigInteger(), //보낼 수량 (단위: wei)
    txGasPrice = "10000000000".toBigInteger(), //Gas Price (단위: wei)
    contractAddress: "0x1234...", //Contract Address
    txInput: "0x123456....", //Data
    assetId = 6L, //보낼 자산 asset ID
    maxPriorityPerGas = BigInteger.ZERO, //ETH 전송일 경우 사용
    maxFeePerGas = BigInteger.ZERO, // ETH전송일 경우 사용
    txGasLimit = "21000".toBigInteger() // Gas Limit
)
</code></pre>

## 티켓 정보 확인

TicketUuid로 해당 Uuid에 해당하는 Ticket 정보를 조회합니다.

```kotlin
val info = fncyWallet.getTicketInfo(
    ticketUuid = "ticketUuid", // Ticekt UUID
)
```

#### See Also

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

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

## 티켓 전송

{% hint style="info" %}
티켓 전송은 서버에 등록된 티켓 정보를 사용하여 실제 트랜잭션 실행을 요청합니다.&#x20;

티켓 전송이 성공하면 해당 트랜잭션 이력은 블록체인에 영구적으로 포함되며 변경하거나 취소할 수 없습니다.
{% endhint %}

**발행된 티켓UUID**와 **지갑 비밀번호**를 전달하여 해당 티켓 정보로 실제 트랜잭션을 실행시킵니다.&#x20;

티켓UUID를 얻는 방법은 [티켓 생성](#undefined-2)을 확인하십시오.

```kotlin
val result = fncyWallet.sendTicket(
    ticketUuids = "ticketUuid", // Ticekt UUID
    pinNumber = "000000" // 지갑 비밀번호
)
```

#### See Also

[sendTicket](https://docs.fncy.world/fncy-2.0.2-kor/for-developers/wallet/sdk/methods#suspend-fun-sendticket)

[^1]: <https://app.gitbook.com/o/sxbvsaQu6S0zvfR1DBLL/s/XGH1RW6E8fNQHFadoXQF/~/changes/13/for-developers/mobile-app/fncy-wallet-sdk/ios/methods#func-getgasprice>
