How to process Operations
After you created an Operation, the operation needs to be signed for. You could handle this in various ways, but we do recommend using our provided SDKs.
Our web identity platform and SDKs will take care of Operations that require more than one transaction - for example when user has to approve a certain contract before performing an on-chain transaction using it.
Using our SDK
When using our SDK, processing an operation is as simple as providing the user entity id and the operation id. The SignOperation
method will automatically open a browser or sign it with an existing Session.
var operationId = "clxn9u(...)0c4bz7av";
var operationResult = await m_BeamClient.SignOperationAsync(
entityId: "your-entity-id",
operationId: operationId,
signingBy: OperationSigningBy.Auto // accepts Auto, Browser and Session
);
if (operationResult.Status == BeamResultType.Success)
{
var operationStatus = operationResult.Result;
var isApproved = operationResult.Result == CommonOperationResponse.StatusEnum.Executed;
var isRejected = operationResult.Result == CommonOperationResponse.StatusEnum.Rejected;
// (...)
}
Using the provided URL
As you might have seen when creating an Operation, we return a url
property in the response. The url
is a URL to our web interface, which the user can use in order to sign for the Operation.
Please note that if you use the web interface, we won’t provide you with a proper callback about the status of the Operation. You will need to poll our API’s getOperation method periodically in order to know about status changes in the Operation based on user actions.
// {
// "status": "Pending",
// "id": "clwt0h7ej000c2jckyr2nh0cv",
// "createdAt": "2024-05-30T08:46:42.620Z",
// "updatedAt": null,
// "gameId": "cltr8rde601aeakka28hbtuim",
// "userId": "clwdehitt005biwog2szib1fh",
// "chainId": 13337,
// "url": "https://identity.testnet.onbeam.com/games/cltr8rde601aeakka28hbtuim/operation/clwt0h7ej000c2jckyr2nh0cv/confirm",
// "game": {
// ...
// },
// "transactions": [
// ...
// ]
// }