### Fetch Lock Settings with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/get-lock-settings-by-slug Example implementation using C# HttpClient to perform the GET request. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/lock-settings/slug/:slug"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Fetch Price with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/price Example of how to perform a GET request to the price endpoint using C# HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/:network/price"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Install the Hardhat Plugin Source: https://docs.unlock-protocol.com/tools/hardhat-plugin Install the plugin using npm or yarn. ```bash npm i @unlock-protocol/hardhat-plugin ``` ```bash yarn add @unlock-protocol/hardhat-plugin ``` -------------------------------- ### Install Dependencies Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/hooks/using-on-key-purchase-hook-to-password-protect Install the Unlock Hardhat plugin and OpenZeppelin contracts for ECDSA verification. ```bash npm install --save @unlock-protocol/hardhat-plugin npm install --save @openzeppelin/contracts ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/get-data-for-recipients-and-captcha Example of how to perform the GET request using C# HttpClient with Bearer token authentication. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/api/captcha"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Example metadataInputs configuration Source: https://docs.unlock-protocol.com/tools/checkout/collecting-metadata A comprehensive example showing various input types like text, email, date, color, and checkbox. ```json "metadataInputs":[ { "name":"First Name", "defaultValue":"", "type":"text", "required":false, "placeholder":"John Doe", "public":false }, { "name":"Last Name", "defaultValue":"", "type":"text", "required":false, "placeholder":"Doe", "public":false }, { "name":"Email", "defaultValue":"", "type":"email", "required":true, "placeholder":"john@doecorp.xyz", "public":false }, { "name":"DOB", "defaultValue":"", "type":"date", "required":false, "placeholder":"", "public":false }, { "name":"Favorite Color", "defaultValue":"", "type":"color", "required":false, "placeholder":"", "public":false }, { "name":"Website", "defaultValue":"", "type":"url", "required":false, "placeholder":"https://example-url.com", "public":false }, { "name":"Subscribe to our mailing list", "defaultValue":"false", "type":"checkbox", "required":false, "public":false } ] ``` -------------------------------- ### Setup Payment Method Endpoint Source: https://docs.unlock-protocol.com/api/locksmith/setup-payment The POST request to the /v2/purchase/setup endpoint to initiate a payment setup intent. ```http POST ## /v2/purchase/setup ``` -------------------------------- ### Success Response Example Source: https://docs.unlock-protocol.com/api/locksmith/update-users-metadata Example of a successful 201 response containing the created user metadata. ```json { "result": [ { "network": 0, "lockAddress": "string", "userAddress": "string", "metadata": { "public": {}, "protected": {} } } ], "error": [ "string" ] } ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/get-checkout-config Example implementation using C# HttpClient to retrieve the checkout configuration. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/checkout/:id"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Nonce with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/nonce Example implementation using C# HttpClient to fetch the nonce. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/auth/nonce"); request.Headers.Add("Accept", "html/text"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/get-user-private-key Example implementation using C# HttpClient to retrieve the private key. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/users/:emailAddress/privatekey"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### POST /v2/purchase/setup Source: https://docs.unlock-protocol.com/api/locksmith/setup-payment Initializes a payment setup intent for the authenticated user. ```APIDOC ## POST /v2/purchase/setup ### Description Setup a payment method for the user by creating a setup intent client secret. ### Method POST ### Endpoint /v2/purchase/setup ### Response #### Success Response (200) - Created setup intent client secret. #### Error Response (401) - User is not authenticated. ``` -------------------------------- ### Generate Certificate Request (C#) Source: https://docs.unlock-protocol.com/api/locksmith/generate-certificate Example using HttpClient to perform a GET request to the certificate generation endpoint. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/certificate/:network/lock/:lockAddress/key/:keyId/generate"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Success Response Example Source: https://docs.unlock-protocol.com/api/locksmith/save-lock-setting Example of a successful response body when saving lock settings. ```json { "sendEmail": true } ``` -------------------------------- ### Approve Event C# Example Source: https://docs.unlock-protocol.com/api/locksmith/approve-event Example implementation using HttpClient in C#. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/event-collection/:slug/events/approve"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"eventSlug\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Receipt Request with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/get-receipt Example implementation using C# HttpClient to fetch receipt data. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/receipts/:network/:lockAddress/:hash"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Successful Response Example Source: https://docs.unlock-protocol.com/api/locksmith/bulk-approve-events Example JSON response returned upon successfully approving the selected events. ```json [ { "id": 0, "eventSlug": "string", "collectionSlug": "string", "isApproved": true, "createdAt": "2024-07-29T15:51:28.071Z", "updatedAt": "2024-07-29T15:51:28.071Z" } ] ``` -------------------------------- ### Add Manager Request Example Source: https://docs.unlock-protocol.com/api/locksmith/add-manager-to-event-collection Example of the request body required to add a new manager. ```json { "newManagerAddress": "string" } ``` -------------------------------- ### HttpClient C# Request Example Source: https://docs.unlock-protocol.com/api/locksmith/approve-rsvp Example implementation using C# HttpClient to perform the POST request. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/rsvp/:network/:lockAddress/approve/:userAddress"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Generate Ticket with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/generate-ticket Example implementation using C# HttpClient to perform the GET request with an authorization header. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/ticket/:network/lock/:lockAddress/key/:keyId/generate"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Install Unlock Protocol Contracts Source: https://docs.unlock-protocol.com/core-protocol Install the npm package to access contract artifacts and interfaces. ```bash yarn add @unlock-protocol/contracts ``` -------------------------------- ### signTicket C# HttpClient Example Source: https://docs.unlock-protocol.com/api/locksmith/sign-ticket Example implementation using C# HttpClient to request a signature. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/ticket/:network/:lockAddress/:keyId/sign"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/delete-application Example of how to perform an authenticated request using C# HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/bulk-approve-events Example implementation using C# HttpClient to perform the bulk approval request. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/event-collection/:slug/events/bulk-approve"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"eventSlugs\": [\n \"string\"\n ]\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Capture Purchase C# HttpClient Example Source: https://docs.unlock-protocol.com/api/locksmith/capture-purchase Example implementation using C# HttpClient to send a POST request to the capture endpoint. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/purchase/capture"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"recipients\": [\n \"string\"\n ],\n \"network\": 0,\n \"lock\": \"string\",\n \"userAddress\": \"string\",\n \"paymentIntent\": \"string\",\n \"data\": [\n \"string\"\n ],\n \"referrers\": [\n \"string\"\n ],\n \"purchaseType\": \"extend\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/connect-stripe-account Example implementation using C# HttpClient to connect a Stripe account. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/stripe/connect/:network/locks/:lockAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"baseUrl\": \"string\",\n \"stripeAccount\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Success Response Example Source: https://docs.unlock-protocol.com/api/locksmith/get-event-collections-by-manager Example JSON response structure for a successful request. ```json [ { "slug": "string", "title": "string", "description": "string", "coverImage": "string", "banner": "string", "links": {}, "managerAddresses": [ "string" ], "createdAt": "2024-07-29T15:51:28.071Z", "updatedAt": "2024-07-29T15:51:28.071Z", "events": [ { "name": "string", "slug": "string", "image": "string", "description": "string", "status": "pending", "transactionHash": "string", "eventType": "unlock", "attributes": [ { "trait_type": "string", "value": "string" } ] } ] } ] ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/verifiers Example of how to perform a GET request to the verifier list endpoint using C# HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/verifier/list/:network/:lockAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/add-event-verifier Example implementation using C# HttpClient to add a verifier. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Put, "https://locksmith.unlock-protocol.com/v2/events/:slug/verifiers/:verifierAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"verifierName\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/bulk-remove-events Example implementation using C# HttpClient to perform the bulk removal. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Delete, "https://locksmith.unlock-protocol.com/v2/event-collection/:slug/events/bulk-remove"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"eventSlugs\": [\n \"string\"\n ]\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Example Checkout URL Source: https://docs.unlock-protocol.com/tools/checkout/configuration A complete example of a checkout URL including a URL-encoded paywall configuration and a redirect URI. ```text https://app.unlock-protocol.com/checkout?redirectUri=https://unlock-protocol.com/blog&paywallConfig=%7B%22locks%22%3A%7B%220x15F67811Beb43aCE162693fe1415916F87B8C5C2%22%3A%7B%22network%22%3A137%7D%7D%2C%22persistentCheckout%22%3Atrue%7D ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/approved-refunds Example of how to perform a GET request to the approved refunds endpoint using C# HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/events/approved-refunds/:slug"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Example Source: https://docs.unlock-protocol.com/api/locksmith/get-event-collection Example implementation using C# HttpClient to fetch event collection data. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/event-collection/:slug"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Not Found Error Example Source: https://docs.unlock-protocol.com/api/locksmith/add-event-to-collection The JSON structure returned when the requested resource does not exist. ```json { "message": "resource not found" } ``` -------------------------------- ### Response Schema Example Source: https://docs.unlock-protocol.com/api/locksmith/get-data-for-recipients-and-gitcoin-passport The expected JSON structure for a successful response. ```json { "result": [ "string" ] } ``` -------------------------------- ### Download Receipts with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/download-receipts Example implementation using C# HttpClient to fetch the ZIP file. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/receipts/download/:network/:lockAddress"); request.Headers.Add("Accept", "application/zip"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GET /v2/checkout/list Source: https://docs.unlock-protocol.com/api/locksmith/list-checkout-configs Retrieves a list of all checkout configurations created by the authenticated user. ```APIDOC ## GET /v2/checkout/list ### Description A list of all checkout configs created by the user. ### Method GET ### Endpoint /v2/checkout/list ### Response #### Success Response (200) - Checkout config for the updated id. #### Error Response (401) - User is not authenticated. ``` -------------------------------- ### C# HttpClient Implementation Source: https://docs.unlock-protocol.com/api/locksmith/create-verifier Example implementation using C# HttpClient to perform the PUT request. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Put, "https://locksmith.unlock-protocol.com/v2/api/verifier/:network/:lockAddress/:verifierAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var content = new StringContent("{\n \"verifierName\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GET /v2/applications/list Source: https://docs.unlock-protocol.com/api/locksmith/applications Retrieves a list of applications created by the authenticated user. ```APIDOC ## GET https://locksmith.unlock-protocol.com/v2/applications/list ### Description List applications created by the authenticated user. ### Method GET ### Endpoint https://locksmith.unlock-protocol.com/v2/applications/list ### Authorization Requires Bearer Token (JWT). ### Response #### Success Response (200) - **results** (object[]) - Array of application objects - **id** (number) - Application ID - **name** (string) - Application name - **key** (string) - Application key (nullable) - **walletAddress** (string) - Associated wallet address #### Response Example { "results": [ { "id": 0, "name": "string", "key": "string", "walletAddress": "string" } ] } #### Error Responses - **403**: User is not authorized or authenticated to perform this action. - **500**: Internal server error. ``` -------------------------------- ### Full paywallConfig Example Source: https://docs.unlock-protocol.com/tools/checkout/configuration A complete JSON configuration object demonstrating lock definitions, network settings, and metadata input requirements. ```json { "pessimistic": true, "locks": { "0x250a0153DfB52B44c560524283A6629C1d347545": { "network": 1, "name": "Unlock members" } }, "icon": "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Ftse1.mm.bing.net%2Fth%3Fid%3DOIP.10UUFNA8oLdFdDpzt-Em_QHaHa%26pid%3DApi&f=1", "metadataInputs": [ { "name": "Name", "type": "text", "required": true } ] } ``` -------------------------------- ### Successful Response Example Source: https://docs.unlock-protocol.com/api/locksmith/get-event JSON structure returned upon a successful event retrieval. ```json { "id": 0, "data": { "name": "string", "slug": "string", "image": "string", "description": "string", "attributes": [ { "trait_type": "string", "value": "string" } ] }, "checkoutConfig": { "id": "string", "name": "string", "by": "string", "config": { "locks": {} }, "createdAt": "2024-07-29T15:51:28.071Z", "updatedAt": "2024-07-29T15:51:28.071Z" }, "slug": "string" } ``` -------------------------------- ### GET /v2/api/:network/locks/:lockAddress/export-keys Source: https://docs.unlock-protocol.com/api/locksmith/export-keys Starts a job process to retrieve all keys for the specified lock. ```APIDOC ## GET /v2/api/:network/locks/:lockAddress/export-keys ### Description Starts a job process to get all the keys for the given lock. ### Method GET ### Endpoint /v2/api/:network/locks/:lockAddress/export-keys ### Parameters #### Path Parameters - **network** (string) - Required - The network identifier. - **lockAddress** (string) - Required - The address of the lock. ### Response #### Success Response (200) - Successfully started Keys Job #### Error Responses - 401: Unauthorized - 404: Not Found ``` -------------------------------- ### Request Body Example Source: https://docs.unlock-protocol.com/api/locksmith/update-lock-metadata The structure of the metadata object in the request body. ```json { "metadata": {} } ``` -------------------------------- ### Generate Pass with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/generate-apple-wallet-pass Example implementation using C# HttpClient to fetch the pass file. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/pass/:network/:lockAddress/:keyId/ios"); request.Headers.Add("Accept", "application/vnd.apple.pkpass"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Initialize Hardhat Project Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/hooks/using-on-key-purchase-hook-to-password-protect Commands to create a new directory and initialize a Hardhat project. ```bash mkdir password-hook cd password-hook npx hardhat ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/ticket-verification-url Example implementation using C# HttpClient to fetch the verification URL. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/ticket/:network/:lockAddress/:keyId/verification"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Stripe Connections Request Source: https://docs.unlock-protocol.com/api/locksmith/get-stripe-connections Example request using C# HttpClient to retrieve connected locks. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/stripe/connections"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/get-event-details Example implementation using C# HttpClient to fetch event details. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/events/:network/:lockAddress"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Create Hook Source File Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/hooks/using-on-key-purchase-hook-to-password-protect Command to create the Solidity file for the purchase hook. ```bash touch contracts/PurchaseHook.sol ``` -------------------------------- ### Example of a signed message Source: https://docs.unlock-protocol.com/tools/sign-in-with-ethereum A sample format of the message signed by the user during the authentication flow. ```text ouvre-boite.com wants you to sign in with your Ethereum account: 0xDD8e2548da5A992A63aE5520C6bC92c37a2Bcc44 URI: https://app.unlock-protocol.com/login Version: 1 Nonce: rokvh2jf Issued At: 2022-02-04T18:43:17.178Z ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/get-exported-keys Example implementation using C# HttpClient to retrieve exported keys. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/:network/locks/:lockAddress/export-keys/:jobId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Initialize Proxy Admin Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV11 Deploys a ProxyAdmin contract used to upgrade locks. ```solidity function initializeProxyAdmin() external ``` -------------------------------- ### Retrieve Ticket via C# HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/get-event-ticket Example implementation using C# HttpClient to perform a GET request with bearer token authentication. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/ticket/:slug/:network/lock/:lockAddress/key/:keyId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Check Ticket Request with HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/check-ticket Example of how to perform the check-in request using C# HttpClient. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Put, "https://locksmith.unlock-protocol.com/v2/api/ticket/:network/lock/:lockAddress/key/:keyId/check"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Retrieve Lock Charges using C# HttpClient Source: https://docs.unlock-protocol.com/api/locksmith/get-charges-for-lock Example implementation using C# HttpClient to perform a GET request to the locksmith API. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/charges/:network/locks/:lockAddress"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Fetch Key Metadata with C# Source: https://docs.unlock-protocol.com/api/locksmith/key-metadata Example using HttpClient to retrieve key metadata with Bearer token authentication. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/api/metadata/:network/locks/:lockAddress/keys/:keyId"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/get-data-for-recipients-and-gitcoin-passport Example implementation using C# HttpClient to fetch data from the endpoint. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/hooks/gitcoin"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Success Response Example Source: https://docs.unlock-protocol.com/api/locksmith/check-event-ticket JSON response body returned when the ticket is successfully checked in. ```json { "message": "Successfully fulfilled the request." } ``` -------------------------------- ### Success Response Example Source: https://docs.unlock-protocol.com/api/locksmith/add-event-to-collection The JSON structure returned upon successfully adding an event to a collection. ```json { "id": 0, "eventSlug": "string", "collectionSlug": "string", "isApproved": true, "createdAt": "2024-07-29T15:51:28.071Z", "updatedAt": "2024-07-29T15:51:28.071Z" } ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/create-download-receipts-request Example implementation using C# HttpClient to trigger the receipt generation. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/receipts/all/:network/:lockAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Unauthorized Error Example Source: https://docs.unlock-protocol.com/api/locksmith/bulk-approve-events Example JSON response when the user is not authorized or authenticated. ```json { "message": "You are not authorized or authenticated to perform this action." } ``` -------------------------------- ### Deploying Unlock Contracts via CLI Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/deploying-locally Execute the deployment script for the Unlock contracts on a local network. ```bash yarn hardhat unlock:deploy --network localhost ``` -------------------------------- ### C# HttpClient Verification Request Source: https://docs.unlock-protocol.com/api/locksmith/verify-email-code Example implementation using HttpClient to verify an email code. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://locksmith.unlock-protocol.com/v2/api/users/:emailAddress/verify-email-code"); request.Headers.Add("Accept", "application/json"); var content = new StringContent("{\n \"code\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Request Body Example Source: https://docs.unlock-protocol.com/api/locksmith/add-event-to-collection The required JSON body for the POST request containing the event slug. ```json { "eventSlug": "string" } ``` -------------------------------- ### C# HttpClient Request Source: https://docs.unlock-protocol.com/api/locksmith/get-receipts-status Example implementation using C# HttpClient to fetch receipt status. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/receipts/all/:network/:lockAddress"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### unlock.deployProtocol() Source: https://docs.unlock-protocol.com/tools/hardhat-plugin Deploys the entire Unlock protocol stack (localhost only). ```APIDOC ## unlock.deployProtocol() ### Description Deploys the entire Unlock protocol suite. This method is intended for use on local development networks. ### Usage ```javascript await unlock.deployProtocol(); ``` ``` -------------------------------- ### Initialize Paywall with npm module Source: https://docs.unlock-protocol.com/tutorials/front-end/locking-page Use the Paywall class to configure networks and trigger the checkout modal in JavaScript or TypeScript environments. ```javascript import { Paywall } from '@unlock-protocol/paywall' // See https://docs.unlock-protocol.com/getting-started/locking-page#configure-the-paywall const paywallConfig = {} // Configure networks to use // You can also use @unlock-protocol/networks for convenience... const networkConfigs = { 1: { provider: 'HTTP PROVIDER', }, 100: { // configuration for gnosis chain... etc }, // etc } const paywall = new Paywall(networks) // Loads the checkout UI const response = await paywall.loadCheckoutModal(paywallConfig) // response is set when the modal is closed. response may include hash (the transaction hash) and lock (the address of the lock to which the transaction was sent) ``` -------------------------------- ### Generate Google Wallet Pass with C# Source: https://docs.unlock-protocol.com/api/locksmith/generate-google-wallet-pass Example request using HttpClient in C# to retrieve the wallet pass URL. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://locksmith.unlock-protocol.com/v2/pass/:network/:lockAddress/:keyId/android"); request.Headers.Add("Accept", "application/json"); request.Headers.Add("Authorization", "Bearer "); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Event Details Endpoint URL Source: https://docs.unlock-protocol.com/api/locksmith/get-event-details The base URL structure for the GET request to retrieve event details. ```http GET ## https://locksmith.unlock-protocol.com/v2/events/:network/:lockAddress ``` -------------------------------- ### GET https://locksmith.unlock-protocol.com/v2/api/charges/:network/locks/:lockAddress Source: https://docs.unlock-protocol.com/api/locksmith/get-charges-for-lock Get the price breakdown for recipients & total charges with fees for a specific lock. ```APIDOC ## GET https://locksmith.unlock-protocol.com/v2/api/charges/:network/locks/:lockAddress ### Description Get the price breakdown for recipients & total charges with fees for a specific lock. ### Method GET ### Endpoint https://locksmith.unlock-protocol.com/v2/api/charges/:network/locks/:lockAddress ### Parameters #### Path Parameters - **network** (integer) - Required - Network id. - **lockAddress** (string) - Required - Lock address. #### Query Parameters - **purchaseData[]** (string[]) - Required - The purchase data passed to the purchase function - **recipients[]** (string[]) - Required - The recipients passed to the purchase function ### Response #### Success Response (200) - **total** (number) - Total cost - **symbol** (string) - Currency symbol - **creditCardProcessingFee** (number) - Credit card processing fee - **unlockServiceFee** (number) - Unlock service fee - **gasCost** (number) - Gas cost - **prices** (object[]) - Array of price details per user #### Response Example { "total": 0, "symbol": "string", "creditCardProcessingFee": 0, "unlockServiceFee": 0, "gasCost": 0, "prices": [ { "userAddress": "string", "amount": "string", "symbol": "string" } ] } ``` -------------------------------- ### POST /v2/applications Source: https://docs.unlock-protocol.com/api/locksmith/create-application Creates a new application associated with a user wallet. ```APIDOC ## POST https://locksmith.unlock-protocol.com/v2/applications ### Description Create an application associated with a user wallet. ### Method POST ### Endpoint https://locksmith.unlock-protocol.com/v2/applications ### Request Body - **name** (string) - Required - The name of the application. - **key** (string) - Optional - The application key. - **walletAddress** (string) - Required - The wallet address associated with the application. ### Request Example { "name": "string", "key": "string", "walletAddress": "string" } ### Response #### Success Response (201) - **id** (number) - The unique identifier of the created application. - **name** (string) - The name of the application. - **key** (string) - The application key. - **walletAddress** (string) - The wallet address associated with the application. #### Response Example { "id": 0, "name": "string", "key": "string", "walletAddress": "string" } #### Error Responses - **400**: Invalid input received. - **403**: User is not authorized to perform this action. - **500**: Internal server error. ``` -------------------------------- ### symbol Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV9 Gets the token symbol. ```APIDOC ## symbol() ### Description Gets the token symbol. ### Returns - **[0]** (string) - string representing the token symbol ``` -------------------------------- ### initialize Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV13 Initializes the Unlock contract with the specified owner. ```APIDOC ## function initialize(address _unlockOwner) ### Description Initializes the Unlock contract with the specified owner address. ### Parameters - **_unlockOwner** (address) - Required - The address of the owner of the Unlock contract. ``` -------------------------------- ### initialize Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV12 Initializes a new lock with the specified parameters. ```APIDOC ## initialize ### Description Initializes a new lock with the specified creator, duration, token address, price, capacity, and name. ### Parameters - **_lockCreator** (address) - **_expirationDuration** (uint256) - **_tokenAddress** (address) - **_keyPrice** (uint256) - **_maxNumberOfKeys** (uint256) - **_lockName** (string) ``` -------------------------------- ### Get OnKeyCancel Hook Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV14 Returns the address of the onKeyCancelHook. ```solidity function onKeyCancelHook() external view returns (address hookAddress) ``` -------------------------------- ### Get OnKeyPurchase Hook Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV14 Returns the address of the onKeyPurchaseHook. ```solidity function onKeyPurchaseHook() external view returns (address hookAddress) ``` -------------------------------- ### Install Unlock Protocol Contracts Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api Commands to add the Unlock Protocol contract interfaces to your project using package managers. ```shell yarn add @unlock-protocol/contracts ``` ```shell npm i @unlock-protocol/contracts ``` -------------------------------- ### gasRefundValue Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/PublicLock Gets the current gas refund value. ```APIDOC ## function gasRefundValue() ### Description Returns the value/price to be refunded to the sender on purchase. ``` -------------------------------- ### Purchase Membership NFT with Ethers.js Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/ethers Demonstrates how to connect a wallet signer and execute a purchase transaction on a lock contract. ```javascript const ethers = require('ethers') const abis = require('@unlock-protocol/contracts') // Wrapping all calls in an async block const run = async () => { // Here we use a provider. We will be able to read the state, but not send transactions. const provider = new ethers.providers.JsonRpcProvider( 'https://rpc.unlock-protocol.com/11155111' ) // This time, we also need a signer. // Note: we sent some fake Eth to this address, but please replace with your own! const wallet = ethers.Wallet.fromMnemonic( 'seed cube fiction obvious cover riot edge beauty pelican radio useful strong' ) const signer = wallet.connect(provider) // We will interact with a lock deployed on goerli at this address 0xc4d21c3b2e2b94b2520c00ec3f5f49b3874a2bb5 const address = '0xc4d21c3b2e2b94b2520c00ec3f5f49b3874a2bb5' // Let's go purchase the membership for this lock const lock = new ethers.Contract(address, abis.PublicLockV14.abi, signer) // If the lock was using an ERC20 as currency, we would need to send an approval transaction on the ERC20 contract first... // Let's get the key price so we know how much we need to send (we could send more!) const amount = await lock.keyPrice() // Purchase params: // The purchase function in v11 supports making multiple purchases... here we just pass a single one. const purchaseParams = [ [amount], [wallet.address], // This is the recipient of the membership (us!) [wallet.address], // The is the referrer who will earn UDT tokens (we'd like this to be us!) [ethers.constants.AddressZero], // The key manager. if 0x0, then it is the recipient by default [[]], // empty data object (not used here) ] const options = { value: amount, // This is a lock that uses Ether, so it means we need send value. If it was an ERC20 we could set this to 0 and just use the amount on purchase's first argument } // We can now send transactions to modify the state of the lock, like purchase a key! const transaction = await lock.purchase(...purchaseParams, options) console.log(transaction.hash) const receipt = await transaction.wait() console.log(receipt) } run() ``` -------------------------------- ### Get Token Symbol Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV10 Retrieves the symbol associated with the token. ```solidity function symbol() external view returns (string) ``` -------------------------------- ### Get Chain ID Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV11 Retrieves the current chain ID. ```solidity function chainId() external view returns (uint256) ``` -------------------------------- ### GET /v2/auth/user Source: https://docs.unlock-protocol.com/api/locksmith/user Retrieves the details of the currently authenticated user. ```APIDOC ## GET /v2/auth/user ### Description Retrieves the details of the currently authenticated user. ### Method GET ### Endpoint https://locksmith.unlock-protocol.com/v2/auth/user ### Authorization Bearer Token (JWT) ### Response #### Success Response (200) - **walletAddress** (string) - The wallet address of the user. #### Response Example { "walletAddress": "string" } #### Error Response (500) - **message** (string) - Error message indicating the request could not be fulfilled. ``` -------------------------------- ### Connect EIP 1193 Provider to Paywall Source: https://docs.unlock-protocol.com/tools/sign-in-with-ethereum/unlock-accounts Initialize the Paywall instance and connect an EIP 1193 provider to load the checkout modal. ```javascript import { Paywall } from '@unlock-protocol/paywall' import { networks } from '@unlock-protocol/networks' const paywall = new Paywall(networks) paywall.connect(provider) // EIP 1193 provider paywall.loadCheckoutModal({...}) ``` -------------------------------- ### Successful Response JSON Source: https://docs.unlock-protocol.com/api/locksmith/check-privy-user Example of a successful response containing user existence status and profile details. ```json { "exists": true, "user": { "id": "string", "createdAt": "2024-07-29T15:51:28.071Z", "isGuest": true, "customMetadata": {}, "linkedAccounts": [ {} ], "email": { "address": "user@example.com", "verifiedAt": "2024-07-29T15:51:28.071Z", "firstVerifiedAt": "2024-07-29T15:51:28.071Z", "latestVerifiedAt": "2024-07-29T15:51:28.071Z" }, "wallet": { "address": "string", "chainType": "string", "verifiedAt": "2024-07-29T15:51:28.071Z", "firstVerifiedAt": "2024-07-29T15:51:28.071Z", "latestVerifiedAt": "2024-07-29T15:51:28.071Z" } } } ``` -------------------------------- ### Request Body Example Source: https://docs.unlock-protocol.com/api/locksmith/add-event-verifier The JSON body required for the addEventVerifier request. ```json { "verifierName": "string" } ``` -------------------------------- ### Import the Plugin in Hardhat Config Source: https://docs.unlock-protocol.com/tools/hardhat-plugin Register the plugin in your Hardhat configuration file. ```javascript require('@unlock-protocol/hardhat-plugin') ``` ```typescript import '@unlock-protocol/hardhat-plugin' ``` -------------------------------- ### Get total supply Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV11 Returns the total number of tokens in existence. ```solidity function totalSupply() external view returns (uint256) ``` -------------------------------- ### Get collection name Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/PublicLock/IPublicLockV11 Returns the descriptive name for the NFT collection. ```solidity function name() external view returns (string _name) ``` -------------------------------- ### networkBaseFee Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV11 Helper to get the network mining basefee as introduced in EIP-1559. ```APIDOC ## function networkBaseFee() ### Description Helper to get the network mining basefee as introduced in EIP-1559. This helper can be wrapped in try/catch statement to avoid revert in networks where EIP-1559 is not implemented. ### Signature `function networkBaseFee() external view returns (uint256)` ``` -------------------------------- ### Record Key Purchase Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV11 Tracks added GDP and grants discount tokens to the referrer. Invoked by a previously deployed lock. ```solidity function recordKeyPurchase(uint256 _value, address _referrer) external ``` -------------------------------- ### Get Global Token Symbol Source: https://docs.unlock-protocol.com/core-protocol/smart-contracts-api/archive/Unlock/IUnlockV11 Retrieves the global token symbol. ```solidity function globalTokenSymbol() external view returns (string) ``` -------------------------------- ### Triggering a purchase with Thirdweb React SDK Source: https://docs.unlock-protocol.com/tutorials/misc/thirdweb Example of using the useContract and useContractWrite hooks to execute a purchase function on a deployed smart contract. ```typescript import { useContract, useContractWrite } from "@thirdweb-dev/react"; export default function Component() { const { contract } = useContract( "0x2C2fb85b9Eb615Ed2a008B9225E187cCd30cdF1c" ); const { mutateAsync: purchase, isLoading } = useContractWrite( contract, "purchase" ); const call = async () => { try { const data = await purchase([ _values, _recipients, _referrers, _keyManagers, _data, ]); console.info("contract call success", data); } catch (err) { console.error("contract call failure", err); } }; } ``` -------------------------------- ### GET https://locksmith.unlock-protocol.com/purchase Source: https://docs.unlock-protocol.com/api/locksmith/balance Retrieves balances for purchaser addresses on each network. ```APIDOC ## GET https://locksmith.unlock-protocol.com/purchase ### Description Retrieves balances for purchaser addresses on each network. ### Method GET ### Endpoint https://locksmith.unlock-protocol.com/purchase ### Response #### Success Response (200) - **address** (string) - The address of the purchaser. - **name** (string) - The name associated with the address. - **balance** (string) - The balance for the address. #### Error Response (500) - **message** (string) - Error message indicating an internal server error. ``` -------------------------------- ### API Request Body Example Source: https://docs.unlock-protocol.com/api/locksmith/login-with-privy The JSON body required for the API request. ```json { "accessToken": "string", "walletAddress": "string" } ``` -------------------------------- ### Listing Available Hardhat Commands Source: https://docs.unlock-protocol.com/tutorials/smart-contracts/deploying-locally View all available commands provided by the Unlock Hardhat plugin. ```bash yarn hardhat ```