Search
Search

Transaction: FoXV7AV...mmzb

Signed by
Receiver
Status
Succeeded
Transaction Fee
0.0005 
Deposit Value
0 
Gas Used
5 Tgas
Attached Gas
100 Tgas
Created
June 21, 2024 at 5:33:24pm
Hash
FoXV7AVMPXZVaqggbsJNAxoNE8kmb37tUfrtjvZfmmzb

Actions

Called method: 'set' in contract: social.near
Arguments:
{ "data": { "dev.near": { "widget": { "op-session": { "": "// Widget stores session_id and if it doesn't exists, then it requests account signature and tries to create a session\n\n//const message = props.message ?? \"Hello\";\n//const recipient = props.recipient ?? \"test.near\";\n//const callbackUrl = props.callbackUrl ?? \"http://near.org\";\n//const authUrl = props.authUrl ?? \"http://your-server.org\";\n//const className = props.className;\nconst {\n apiUrl,\n message,\n recipient,\n callbackUrl,\n className,\n storageKey,\n onAuth,\n onLogout,\n resetSession,\n setResetSession,\n pendingAuth,\n setPendingAuth,\n signature,\n publicKey,\n} = props;\n\nlet { session_id, is_signature_valid } = Storage.privateGet(storageKey);\n\nif (resetSession && !pendingAuth) {\n // clear data on Logout\n session_id = null;\n Storage.privateSet(storageKey, null);\n}\n\nconst signatureProvidedAfterRedirect = !!signature && !!publicKey;\n\nif (signatureProvidedAfterRedirect && !state.pendingVerifySignature) {\n window.location.hash = \"\";\n State.init({\n signature,\n publicKey,\n });\n console.log(\"signature & publicKey provided in props \", state);\n // ignore stored session_id if new signature was provided for verification\n session_id = null;\n Storage.privateSet(storageKey, null);\n setPendingAuth(true);\n}\n\nconst nonce = Buffer.alloc(32, \"1\", \"utf8\");\n\nif (typeof onAuth !== \"function\") {\n // console.log(\"Provide onAuth function\");\n onAuth = (data) => console.log(\"onAuth\", data);\n}\n\nif (typeof setResetSession !== \"function\") {\n // console.log(\"Provide setResetSession function\");\n setResetSession = (data) => console.log(\"setResetSession\", data);\n}\n\nif (typeof setPendingAuth !== \"function\") {\n //console.log(\"Provide setPendingAuth function\");\n setPendingAuth = (data) => console.log(\"setPendingAuth\", data);\n}\n\nconst logout = () => {\n Storage.privateSet(storageKey, null);\n State.update({\n signature: undefined,\n publicKey: undefined,\n authAttempts: 0,\n });\n onLogout();\n};\n\nconst verifySignature = () => {\n State.update({ pendingVerifySignature: true });\n const headers = props.headers ?? {};\n asyncFetch(`${apiUrl}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n account_id: context.accountId,\n public_key: state.publicKey,\n signature: state.signature,\n callback_url: callbackUrl,\n }),\n }).then((res) => {\n console.log(\"verifySignature res\", res);\n if (res.ok) {\n if (res.body.is_signature_valid) {\n Storage.privateSet(storageKey, {\n session_id: res.body.session_id,\n is_signature_valid: true,\n timestamp: Date.now(),\n });\n } else {\n logout();\n }\n onAuth(res.body);\n } else {\n setPendingAuth(false);\n }\n State.update({ pendingVerifySignature: false });\n });\n};\n\nconst requestSignature = () => {\n setPendingAuth(true);\n\n State.update({ authAttempts: state.authAttempts ?? 0 + 1 });\n\n Near.signMessage(message, recipient, nonce, callbackUrl).then((e) => {\n console.log(\"signMessage\", e);\n\n State.update({\n signature: e.signature,\n publicKey: e.publicKey,\n });\n\n if (resetSession) {\n setResetSession(false);\n }\n });\n};\n\nconst debug = (str) => {\n console.log(str);\n};\n\nlet isRequestSignature = false;\n\nif (state.authAttempts > 1) {\n console.log(\"Auth failed\");\n return \"Auth failed\";\n}\n\nif (!pendingAuth) {\n if (resetSession) {\n if (!signatureProvidedAfterRedirect) {\n isRequestSignature = true;\n }\n } else {\n if (!session_id) {\n if (!state.pendingVerifySignature) {\n if (state.signature && state.publicKey) {\n verifySignature();\n }\n } else {\n if (!signatureProvidedAfterRedirect) {\n isRequestSignature = true;\n }\n }\n } else {\n onAuth({ session_id });\n }\n }\n} else {\n if (resetSession) {\n if (state.signature && state.publicKey) {\n verifySignature();\n }\n }\n}\n\nif (isRequestSignature) {\n requestSignature();\n}\n\nif (pendingAuth || resetSession) {\n console.log(\"Loading....\");\n return <div>Loading...</div>;\n}\n\nreturn (\n <div class=\"w-100\">\n <div class=\"text-center pt-5\">\n {!session_id && (\n <div class=\"p-2\">\n <h4>Present your idea to AI Product Manager.</h4>\n <p>\n After asking you few questions, AI will write documentation that\n will be passed to developer to build your application\n </p>\n </div>\n )}\n <button class={className} onClick={() => logout()}>\n {session_id ? \"Logout\" : \"Start new working session\"}\n </button>\n </div>\n </div>\n);\n" } } } } }

Transaction Execution Plan

Convert Transaction To Receipt
Gas Burned:
318 Ggas
Tokens Burned:
0.00003 
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
4 Tgas
Tokens Burned:
0.00047 
Called method: 'set' in contract: social.near
Arguments:
{ "data": { "dev.near": { "widget": { "op-session": { "": "// Widget stores session_id and if it doesn't exists, then it requests account signature and tries to create a session\n\n//const message = props.message ?? \"Hello\";\n//const recipient = props.recipient ?? \"test.near\";\n//const callbackUrl = props.callbackUrl ?? \"http://near.org\";\n//const authUrl = props.authUrl ?? \"http://your-server.org\";\n//const className = props.className;\nconst {\n apiUrl,\n message,\n recipient,\n callbackUrl,\n className,\n storageKey,\n onAuth,\n onLogout,\n resetSession,\n setResetSession,\n pendingAuth,\n setPendingAuth,\n signature,\n publicKey,\n} = props;\n\nlet { session_id, is_signature_valid } = Storage.privateGet(storageKey);\n\nif (resetSession && !pendingAuth) {\n // clear data on Logout\n session_id = null;\n Storage.privateSet(storageKey, null);\n}\n\nconst signatureProvidedAfterRedirect = !!signature && !!publicKey;\n\nif (signatureProvidedAfterRedirect && !state.pendingVerifySignature) {\n window.location.hash = \"\";\n State.init({\n signature,\n publicKey,\n });\n console.log(\"signature & publicKey provided in props \", state);\n // ignore stored session_id if new signature was provided for verification\n session_id = null;\n Storage.privateSet(storageKey, null);\n setPendingAuth(true);\n}\n\nconst nonce = Buffer.alloc(32, \"1\", \"utf8\");\n\nif (typeof onAuth !== \"function\") {\n // console.log(\"Provide onAuth function\");\n onAuth = (data) => console.log(\"onAuth\", data);\n}\n\nif (typeof setResetSession !== \"function\") {\n // console.log(\"Provide setResetSession function\");\n setResetSession = (data) => console.log(\"setResetSession\", data);\n}\n\nif (typeof setPendingAuth !== \"function\") {\n //console.log(\"Provide setPendingAuth function\");\n setPendingAuth = (data) => console.log(\"setPendingAuth\", data);\n}\n\nconst logout = () => {\n Storage.privateSet(storageKey, null);\n State.update({\n signature: undefined,\n publicKey: undefined,\n authAttempts: 0,\n });\n onLogout();\n};\n\nconst verifySignature = () => {\n State.update({ pendingVerifySignature: true });\n const headers = props.headers ?? {};\n asyncFetch(`${apiUrl}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify({\n account_id: context.accountId,\n public_key: state.publicKey,\n signature: state.signature,\n callback_url: callbackUrl,\n }),\n }).then((res) => {\n console.log(\"verifySignature res\", res);\n if (res.ok) {\n if (res.body.is_signature_valid) {\n Storage.privateSet(storageKey, {\n session_id: res.body.session_id,\n is_signature_valid: true,\n timestamp: Date.now(),\n });\n } else {\n logout();\n }\n onAuth(res.body);\n } else {\n setPendingAuth(false);\n }\n State.update({ pendingVerifySignature: false });\n });\n};\n\nconst requestSignature = () => {\n setPendingAuth(true);\n\n State.update({ authAttempts: state.authAttempts ?? 0 + 1 });\n\n Near.signMessage(message, recipient, nonce, callbackUrl).then((e) => {\n console.log(\"signMessage\", e);\n\n State.update({\n signature: e.signature,\n publicKey: e.publicKey,\n });\n\n if (resetSession) {\n setResetSession(false);\n }\n });\n};\n\nconst debug = (str) => {\n console.log(str);\n};\n\nlet isRequestSignature = false;\n\nif (state.authAttempts > 1) {\n console.log(\"Auth failed\");\n return \"Auth failed\";\n}\n\nif (!pendingAuth) {\n if (resetSession) {\n if (!signatureProvidedAfterRedirect) {\n isRequestSignature = true;\n }\n } else {\n if (!session_id) {\n if (!state.pendingVerifySignature) {\n if (state.signature && state.publicKey) {\n verifySignature();\n }\n } else {\n if (!signatureProvidedAfterRedirect) {\n isRequestSignature = true;\n }\n }\n } else {\n onAuth({ session_id });\n }\n }\n} else {\n if (resetSession) {\n if (state.signature && state.publicKey) {\n verifySignature();\n }\n }\n}\n\nif (isRequestSignature) {\n requestSignature();\n}\n\nif (pendingAuth || resetSession) {\n console.log(\"Loading....\");\n return <div>Loading...</div>;\n}\n\nreturn (\n <div class=\"w-100\">\n <div class=\"text-center pt-5\">\n {!session_id && (\n <div class=\"p-2\">\n <h4>Present your idea to AI Product Manager.</h4>\n <p>\n After asking you few questions, AI will write documentation that\n will be passed to developer to build your application\n </p>\n </div>\n )}\n <button class={className} onClick={() => logout()}>\n {session_id ? \"Logout\" : \"Start new working session\"}\n </button>\n </div>\n </div>\n);\n" } } } } }
Result:
{ "block_height": "121680128" }
No logs
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
223 Ggas
Tokens Burned:
0 
Transferred 0.0183  to dev.near
Empty result
No logs