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.
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.
StartCoroutine(beamClient.CreateSession(
"entityIdOfYourUser",
actionResult =>
{
if (actionResult.Status == BeamResultType.Success)
{
var session = actionResult.Result;
// you now have an active session that can sign operations
}
},
chainId: 13337, // optional chainId, defaults to 13337
secondsTimeout: 240 // timeout in seconds for getting a result of Session signing from the browser
));
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 APIs' getOperation (opens in a new tab) 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": [
// ...
// ]
// }