> For the complete documentation index, see [llms.txt](https://docs.quipuswap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/entrypoints-overview/permits-entrypoints/permit.md).

# permit

An entrypoint that implements creating of transfer permits. It fully implements [TZIP-017](https://gitlab.com/tezos/tzip/-/blob/master/proposals/tzip-17/tzip-17.md).

### Call parameters

```pascaligo
type blake2b_hash_t     is bytes

type permit_signature_t is michelson_pair(signature, "", blake2b_hash_t, "permit_hash")

type permit_t           is key * permit_signature_t
```

### Usage

{% tabs %}
{% tab title="🌮 Taquito" %}

```javascript
async function getPermitParamsHash(tezos, contract, entrypoint, parameter) {
  const raw_packed = await tezos.rpc.packData({
    data: contract.parameterSchema.Encode(entrypoint, parameter),
    type: contract.parameterSchema.root.typeWithoutAnnotations(),
  });

  return blake.blake2bHex(hex2buf(raw_packed.packed), null, 32);
}

async function createPermitPayload(tezos, contract, entrypoint, params) {
  const signerKey = await tezos.signer.publicKey();
  const permitCounter = await contract.storage().then(storage => storage.storage.permits_counter);
  const paramHash = await getPermitParamsHash(tezos, contract, entrypoint, params);
  const chainId = await tezos.rpc.getChainId();
  const bytesToSign = await tezos.rpc.packData({
    data: permitSchema.Encode({
      0: contract.address,
      1: chainId,
      2: permitCounter,
      3: paramHash,
    }),
    type: permitSchemaType,
  });
  const signature = await tezos.signer.sign(bytesToSign.packed).then(s => s.prefixSig);

  return [signerKey, signature, paramHash];
}

const dexCoreAddress = "KT1...";
const dexCore = await tezos.contract.at(dexCoreAddress);
const transferParams = [
  {
    from_: alice.pkh,
    txs: [
      {
        to_: bob.pkh,
        token_id: 0,
        amount: 100,
      },
      ...
    ],
  },
  ...
];
const [signerKey, signature, permitHash] = await createPermitPayload(tezos, dexCore, "transfer", transferParams);
const operation = await dexCore.methods.permit(signerKey, signature, permitHash).send();

await operation.confirmation();
```

{% endtab %}
{% endtabs %}

### Errors

* `412` - non payable entrypoint (can't accept TEZ tokens during call of an entrypoint).
* `DUP_PERMIT` - user is trying to create duplicate of an existing permit.
* `MISSIGNED` - incorrect signature of a permit.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.quipuswap.com/smart-contracts/dex-2.0/dexcore-contract/entrypoints-overview/permits-entrypoints/permit.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
