Block Profiles
This request is protected by authentication
hint: this means it requires an x-access-token header put in the request with your authentication token.
Lens Profile Manager Compatible: Gasless & Signless
This action can be used through the Lens Profile Manager to enable a gasless and signless experience.
Block a Lens Profile to restrict the authenticated user from any form of interaction with it.
This method can be used to block one or many profiles in a single call.
There are two different approaches you can use to block a profile. Depending on the whitelist status of your app and the settings of the profile you would like to set metadata for, you can use:
- a) Block Profile via Lens Profile Manager (Gasless & Signless)
- b) Block Profile Using TypedData and Broadcasting Onchain via the API (Gasless & Signed)
To decide which approach to use, you can use the following table. Please note that a profile may also have another Profile Manager enabled that is not powered by the Lens API, this is not covered below. To learn more about checking a profile's Profile Manager settings, see Profile Manager.
Is Your App Whitelisted? | Profile has Lens Profiles Manager Enabled? | Approach To Use | |
---|---|---|---|
1 | true | true | Lens Profile Manager |
2 | true | false | TypedData & Broadcast via API |
3 | false | true | TypedData & Self-Funded |
4 | false | false | TypedData & Self-Funded |
a) Block Profile via Lens Profile Manager (Gasless & Signless)
Request
profiles: ProfileId[]
(required)- The profile IDs to block.
ProfileId
is a string.
- The profile IDs to block.
Invocation
const result = await lensClient.profile.block({
profiles: ["PROFILE_ID_TO_BLOCK"],
});
mutation Block {
block(request: { profiles: ["PROFILE_ID_TO_BLOCK"] }) {
... on RelaySuccess {
...RelaySuccess
}
... on LensProfileManagerRelayError {
...LensProfileManagerRelayError
}
}
}
Response
{
"txHash": "0x000000",
"txId": "0x01"
}
{
"reason": "FAILED" // LensProfileManagerRelayErrorReasonType
}
Full Lens Client Example
const result = await lensClient.profile.block({
profiles: ["PROFILE_ID_TO_BLOCK"],
});
const data = result.unwrap();
if (!isRelaySuccess(data)) {
console.log(`Something went wrong`, data);
return;
}
await lensClient.transaction.waitUntilComplete({ txId: data.txId });
b) Block Profile Using TypedData and Broadcasting Onchain via the API (Gasless & Signed)
Request
profiles: ProfileId[]
(required)- The profile IDs to block.
ProfileId
is a string.
- The profile IDs to block.
Invocation
const blockProfilesTypedData =
await lensClient.profile.createBlockProfilesTypedData({
profiles: ["PROFILE_ID_TO_BLOCK"],
});
mutation CreateBlockProfilesTypedData($request: BlockRequest!) {
createBlockProfilesTypedData(request: $request) {
id
expiresAt
typedData {
types {
SetBlockStatus {
name
type
}
}
domain {
name
chainId
version
verifyingContract
}
value {
nonce
deadline
}
}
}
}
Response
{
"id": "0x01",
"expiresAt": "2023-10-01T00:00:00Z",
"typedData": {
"types": {
"SetBlockStatus": [
{ "name": "nonce", "type": "uint256" },
{ "name": "deadline", "type": "uint256" },
{ "name": "profileIds", "type": "uint256[]" },
{ "name": "blockStatus", "type": "bool" }
]
},
"domain": {
"name": "Lens",
"chainId": "1",
"version": "1",
"verifyingContract": "0x0000000"
},
"value": {
"nonce": "0x01",
"deadline": "2023-10-01T01:00:00Z",
"profileIds": ["0x01"],
"blockStatus": true
}
}
}
Full Lens Client Example
const blockProfilesTypedData =
await lensClient.profile.createBlockProfilesTypedData({
profiles: ["PROFILE_ID_TO_BLOCK"],
});
const data = blockProfilesTypedData.unwrap();
const signedTypedData = await wallet._signTypedData(
data.typedData.domain,
data.typedData.types,
data.typedData.value
);
const broadcastResult = await lensClient.transaction.broadcastOnchain({
id: data.id,
signature: signedTypedData,
});
const broadcastResultValue = broadcastResult.unwrap();
if (!isRelaySuccess(broadcastResultValue)) {
console.log(`Something went wrong`, broadcastResultValue);
return;
}
await lensClient.transaction.waitUntilComplete({
txId: broadcastResultValue.txId,
});
console.log(
`Transaction was successfully broadcasted with txId ${broadcastResultValue.txId}`
);
Full GraphQL API Example
Updated about 1 month ago