Search
Search

Transaction: 5j7VRoU...c4qs

Receiver
Status
Succeeded
Transaction Fee
0.00108 
Deposit Value
0 
Gas Used
11 Tgas
Attached Gas
100 Tgas
Created
November 23, 2022 at 5:04:46pm
Hash
5j7VRoUhiY5tjGWUfnsTtM8bRs8xUE97jvbjsjpec4qs

Actions

Called method: 'set' in contract: social.near
Arguments:
{ "data": { "f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb": { "widget": { "answer_poll": { "": "// console.log(\"props: \", props);\nconst accountId = props.accountId;\nconst questionBlockHeight = props.blockHeight;\n// console.log(\"questionBlockHeight: \", questionBlockHeight);\nconst currentAccountId = context.accountId;\n\nconst profile = Social.getr(`${accountId}/profile`);\n\n// You can use this code to know the blockheights of your question in case you need to test. Just use one blockheight in the props.\n// const testBlockHeights = Social.keys(\n// `f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb/post/answer__poll/${questionBlockHeight}`,\n// \"final\",\n// {\n// return_type: \"History\",\n// }\n// );\n\n// console.log(\"testBlockHeights: \", testBlockHeights);\n\nconst question = Social.get(\n `${accountId}/post/poll__question/question`,\n questionBlockHeight\n);\n\n// console.log(\"question: \", question);\n\nconst questionTimestamp = Social.get(\n `${accountId}/post/poll__question/question_timestamp`,\n questionBlockHeight\n);\n\nconst profileLink = (c) => (\n <a\n className=\"text-decoration-none link-dark\"\n href={`#/mob.near/widget/ProfilePage?accountId=${accountId}`}\n >\n {c}\n </a>\n);\n\nconst answerDataFromBlockHeight = Social.keys(\n `*/post/answer__poll/${questionBlockHeight}`,\n \"final\",\n {\n return_type: \"History\",\n }\n);\n// console.log(\"answerDataFromBlockHeight: \", answerDataFromBlockHeight);\n\nlet answersData = Object.keys(answerDataFromBlockHeight).map((key) => {\n // console.log(\"key: \", key)\n return {\n accountId: key,\n // Social.keys returns in the end a an array of blockHeight related to the query.\n // In our case, we only care for one answer, so it's always the first one\n blockHeightOfAnswer:\n answerDataFromBlockHeight[key].post.answer__poll[questionBlockHeight][0],\n };\n});\n\n// console.log(\"answData: \", answersData);\n\nconst haveThisUserAlreadyVoted = () => {\n if (answersData.length == 0) {\n return false;\n }\n for (let i = 0; i < answersData.length; i++) {\n return answersData[i].accountId == currentAccountId;\n }\n};\n\nlet countVotes = answersData.reduce(\n (acc, curr) => {\n let answer = Social.get(\n `${curr.accountId}/post/answer__poll/${questionBlockHeight}/user_vote`,\n curr.blockHeightOfAnswer\n );\n console.log(\"testing answers: \", answer);\n return answer == 1 ? [acc[0] + 1, acc[1]] : [acc[0], acc[1] + 1];\n },\n [0, 0]\n);\n\nconsole.log(\"countVotes: \", countVotes, questionBlockHeight);\n\nconst loadComments = () => {\n // console.log(\"answrDLength: \", answersData.length);\n for (let i = 0; i < answersData.length; i++) {\n // console.log(\"test: \", answersData[i].accountId);\n let answer = Social.get(\n `${answersData[i].accountId}/post/answer__poll/${questionBlockHeight}/user_answers`\n );\n\n // console.log(\"answer: \", answer);\n\n let answerTimeStamp = Social.get(\n `${answersData[i].accountId}/post/answer__poll/${questionBlockHeight}/answer_timestamps`\n );\n\n // console.log(\"answerTimeStamp: \", answerTimeStamp);\n\n if (answer != undefined) {\n return (\n <Widget\n src=\"f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb/widget/answer_poll-comment-container\"\n props={{\n answer: answer,\n answerTimeStamp: answerTimeStamp,\n userName: answersData[i],\n }}\n />\n );\n }\n }\n};\n\nState.init({ vote: \"\", currentAnswer: \"\" });\n// console.log(\"input vote value: \", state.vote, \"textarea value: \", state.currentAnswer);\nconst getForm = () => (\n <div\n style={{\n border: \"1px solid #e9e9e9\",\n borderRadius: \"20px\",\n padding: \"1rem\",\n }}\n >\n {haveThisUserAlreadyVoted() ? (\n <h5>Change your opinion</h5>\n ) : (\n <h5>Give your opinion</h5>\n )}\n\n <p style={{ marginBottom: \"0\" }}>Vote:</p>\n <div className=\"form-check\">\n <input\n key={state.vote}\n className=\"form-check-input\"\n type=\"radio\"\n name=\"flexRadioDefault\"\n id=\"voteYes\"\n value=\"1\"\n onChange={onValueChange}\n checked={state.vote == \"1\"}\n />\n <label className=\"form-check-label\" for=\"voteYes\">\n Yes\n </label>\n </div>\n <div className=\"form-check\">\n <input\n key={state.vote}\n className=\"form-check-input\"\n type=\"radio\"\n name=\"flexRadioDefault\"\n id=\"voteNo\"\n value=\"0\"\n onChange={onValueChange}\n checked={state.vote == \"0\"}\n />\n <label className=\"form-check-label\" for=\"voteNo\">\n No\n </label>\n </div>\n\n <div className=\"form-group\">\n <label for=\"answer\" className=\"font-weight-bold\">\n Write answer:\n </label>\n <textarea\n className=\"form-control mb-1\"\n id=\"answer\"\n rows=\"3\"\n value={state.currentAnswer}\n onChange={(e) => {\n const currentAnswer = e.target.value;\n State.update({ currentAnswer });\n }}\n ></textarea>\n </div>\n <CommitButton\n data={{\n post: {\n answer__poll: {\n [questionBlockHeight]: {\n user_vote: state.vote == \"\" ? answer.userVote : state.vote,\n user_answers: state.currentAnswer,\n answer_timestamps: Date.now(),\n },\n },\n },\n }}\n >\n Confirm\n </CommitButton>\n </div>\n);\n\nfunction onValueChange(e) {\n const vote = e.target.value;\n\n State.update({ vote });\n}\n\nconst timeAgo = (diffSec) =>\n diffSec < 60000\n ? `${(diffSec / 1000) | 0} seconds ago`\n : diffSec < 3600000\n ? `${(diffSec / 60000) | 0} minutes ago`\n : diffSec < 86400000\n ? `${(diffSec / 3600000) | 0} hours ago`\n : `${(diffSec / 86400000) | 0} days ago`;\n\nreturn (\n <div style={{ maxWidth: \"40em\" }}>\n <div\n className=\"d-flex align-items-start\"\n style={{\n padding: \"1.5rem 0\",\n borderBottom: \"1px solid #e9e9e9\",\n }}\n >\n <div>\n {profileLink(\n <a\n className=\"text-decoration-none\"\n //Check how href is done in memes widget of mob.near\n href={`#`}\n >\n <Widget src=\"mob.near/widget/ProfileImage\" props={{ accountId }} />\n </a>\n )}\n </div>\n <div className=\"ms-2 flex-grow-1\" style={{ minWidth: 0 }}>\n <div className=\"d-flex justify-content-start\">\n <div className=\"flex-grow-1 me-1 text-truncate\">\n {profileLink(\n <>\n <span className=\"fw-bold\">{profile.name}</span>\n <span className=\"text-secondary\">@{accountId}</span>\n </>\n )}\n </div>\n <div>\n <small className=\"ps-1 text-nowrap text-muted ms-auto\">\n <i className=\"bi bi-clock me-1\"></i>\n {timeAgo(Date.now() - questionTimestamp)}\n </small>\n </div>\n </div>\n <div>{question}</div>\n <div className=\"d-flex align-items-start\">\n <i\n className=\"bi bi-check-circle-fill\"\n style={{ padding: \"0 0.3rem\" }}\n ></i>\n <p className=\"text-secondary\">{countVotes[1]}</p>\n <i\n className=\"bi bi-x-octagon-fill\"\n style={{ padding: \"0 0.5rem 0 1rem\" }}\n ></i>\n <p className=\"text-secondary\">{countVotes[0]}</p>\n </div>\n <>{loadComments()}</>\n <>{getForm()}</>\n </div>\n </div>\n </div>\n);\n" } } } } }

Transaction Execution Plan

Convert Transaction To Receipt
Gas Burned:
2 Tgas
Tokens Burned:
0.00024 
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
8 Tgas
Tokens Burned:
0.00083 
Called method: 'set' in contract: social.near
Arguments:
{ "data": { "f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb": { "widget": { "answer_poll": { "": "// console.log(\"props: \", props);\nconst accountId = props.accountId;\nconst questionBlockHeight = props.blockHeight;\n// console.log(\"questionBlockHeight: \", questionBlockHeight);\nconst currentAccountId = context.accountId;\n\nconst profile = Social.getr(`${accountId}/profile`);\n\n// You can use this code to know the blockheights of your question in case you need to test. Just use one blockheight in the props.\n// const testBlockHeights = Social.keys(\n// `f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb/post/answer__poll/${questionBlockHeight}`,\n// \"final\",\n// {\n// return_type: \"History\",\n// }\n// );\n\n// console.log(\"testBlockHeights: \", testBlockHeights);\n\nconst question = Social.get(\n `${accountId}/post/poll__question/question`,\n questionBlockHeight\n);\n\n// console.log(\"question: \", question);\n\nconst questionTimestamp = Social.get(\n `${accountId}/post/poll__question/question_timestamp`,\n questionBlockHeight\n);\n\nconst profileLink = (c) => (\n <a\n className=\"text-decoration-none link-dark\"\n href={`#/mob.near/widget/ProfilePage?accountId=${accountId}`}\n >\n {c}\n </a>\n);\n\nconst answerDataFromBlockHeight = Social.keys(\n `*/post/answer__poll/${questionBlockHeight}`,\n \"final\",\n {\n return_type: \"History\",\n }\n);\n// console.log(\"answerDataFromBlockHeight: \", answerDataFromBlockHeight);\n\nlet answersData = Object.keys(answerDataFromBlockHeight).map((key) => {\n // console.log(\"key: \", key)\n return {\n accountId: key,\n // Social.keys returns in the end a an array of blockHeight related to the query.\n // In our case, we only care for one answer, so it's always the first one\n blockHeightOfAnswer:\n answerDataFromBlockHeight[key].post.answer__poll[questionBlockHeight][0],\n };\n});\n\n// console.log(\"answData: \", answersData);\n\nconst haveThisUserAlreadyVoted = () => {\n if (answersData.length == 0) {\n return false;\n }\n for (let i = 0; i < answersData.length; i++) {\n return answersData[i].accountId == currentAccountId;\n }\n};\n\nlet countVotes = answersData.reduce(\n (acc, curr) => {\n let answer = Social.get(\n `${curr.accountId}/post/answer__poll/${questionBlockHeight}/user_vote`,\n curr.blockHeightOfAnswer\n );\n console.log(\"testing answers: \", answer);\n return answer == 1 ? [acc[0] + 1, acc[1]] : [acc[0], acc[1] + 1];\n },\n [0, 0]\n);\n\nconsole.log(\"countVotes: \", countVotes, questionBlockHeight);\n\nconst loadComments = () => {\n // console.log(\"answrDLength: \", answersData.length);\n for (let i = 0; i < answersData.length; i++) {\n // console.log(\"test: \", answersData[i].accountId);\n let answer = Social.get(\n `${answersData[i].accountId}/post/answer__poll/${questionBlockHeight}/user_answers`\n );\n\n // console.log(\"answer: \", answer);\n\n let answerTimeStamp = Social.get(\n `${answersData[i].accountId}/post/answer__poll/${questionBlockHeight}/answer_timestamps`\n );\n\n // console.log(\"answerTimeStamp: \", answerTimeStamp);\n\n if (answer != undefined) {\n return (\n <Widget\n src=\"f2bc8abdb8ba64fe5aac9689ded9491ff0e6fdcd7a5c680b7cf364142d1789fb/widget/answer_poll-comment-container\"\n props={{\n answer: answer,\n answerTimeStamp: answerTimeStamp,\n userName: answersData[i],\n }}\n />\n );\n }\n }\n};\n\nState.init({ vote: \"\", currentAnswer: \"\" });\n// console.log(\"input vote value: \", state.vote, \"textarea value: \", state.currentAnswer);\nconst getForm = () => (\n <div\n style={{\n border: \"1px solid #e9e9e9\",\n borderRadius: \"20px\",\n padding: \"1rem\",\n }}\n >\n {haveThisUserAlreadyVoted() ? (\n <h5>Change your opinion</h5>\n ) : (\n <h5>Give your opinion</h5>\n )}\n\n <p style={{ marginBottom: \"0\" }}>Vote:</p>\n <div className=\"form-check\">\n <input\n key={state.vote}\n className=\"form-check-input\"\n type=\"radio\"\n name=\"flexRadioDefault\"\n id=\"voteYes\"\n value=\"1\"\n onChange={onValueChange}\n checked={state.vote == \"1\"}\n />\n <label className=\"form-check-label\" for=\"voteYes\">\n Yes\n </label>\n </div>\n <div className=\"form-check\">\n <input\n key={state.vote}\n className=\"form-check-input\"\n type=\"radio\"\n name=\"flexRadioDefault\"\n id=\"voteNo\"\n value=\"0\"\n onChange={onValueChange}\n checked={state.vote == \"0\"}\n />\n <label className=\"form-check-label\" for=\"voteNo\">\n No\n </label>\n </div>\n\n <div className=\"form-group\">\n <label for=\"answer\" className=\"font-weight-bold\">\n Write answer:\n </label>\n <textarea\n className=\"form-control mb-1\"\n id=\"answer\"\n rows=\"3\"\n value={state.currentAnswer}\n onChange={(e) => {\n const currentAnswer = e.target.value;\n State.update({ currentAnswer });\n }}\n ></textarea>\n </div>\n <CommitButton\n data={{\n post: {\n answer__poll: {\n [questionBlockHeight]: {\n user_vote: state.vote == \"\" ? answer.userVote : state.vote,\n user_answers: state.currentAnswer,\n answer_timestamps: Date.now(),\n },\n },\n },\n }}\n >\n Confirm\n </CommitButton>\n </div>\n);\n\nfunction onValueChange(e) {\n const vote = e.target.value;\n\n State.update({ vote });\n}\n\nconst timeAgo = (diffSec) =>\n diffSec < 60000\n ? `${(diffSec / 1000) | 0} seconds ago`\n : diffSec < 3600000\n ? `${(diffSec / 60000) | 0} minutes ago`\n : diffSec < 86400000\n ? `${(diffSec / 3600000) | 0} hours ago`\n : `${(diffSec / 86400000) | 0} days ago`;\n\nreturn (\n <div style={{ maxWidth: \"40em\" }}>\n <div\n className=\"d-flex align-items-start\"\n style={{\n padding: \"1.5rem 0\",\n borderBottom: \"1px solid #e9e9e9\",\n }}\n >\n <div>\n {profileLink(\n <a\n className=\"text-decoration-none\"\n //Check how href is done in memes widget of mob.near\n href={`#`}\n >\n <Widget src=\"mob.near/widget/ProfileImage\" props={{ accountId }} />\n </a>\n )}\n </div>\n <div className=\"ms-2 flex-grow-1\" style={{ minWidth: 0 }}>\n <div className=\"d-flex justify-content-start\">\n <div className=\"flex-grow-1 me-1 text-truncate\">\n {profileLink(\n <>\n <span className=\"fw-bold\">{profile.name}</span>\n <span className=\"text-secondary\">@{accountId}</span>\n </>\n )}\n </div>\n <div>\n <small className=\"ps-1 text-nowrap text-muted ms-auto\">\n <i className=\"bi bi-clock me-1\"></i>\n {timeAgo(Date.now() - questionTimestamp)}\n </small>\n </div>\n </div>\n <div>{question}</div>\n <div className=\"d-flex align-items-start\">\n <i\n className=\"bi bi-check-circle-fill\"\n style={{ padding: \"0 0.3rem\" }}\n ></i>\n <p className=\"text-secondary\">{countVotes[1]}</p>\n <i\n className=\"bi bi-x-octagon-fill\"\n style={{ padding: \"0 0.5rem 0 1rem\" }}\n ></i>\n <p className=\"text-secondary\">{countVotes[0]}</p>\n </div>\n <>{loadComments()}</>\n <>{getForm()}</>\n </div>\n </div>\n </div>\n);\n" } } } } }
Empty result
No logs
Receipt:
Predecessor ID:
Receiver ID:
Gas Burned:
424 Ggas
Tokens Burned:
0 
Transferred 0.01823  to f2bc8…142d1789fb
Empty result
No logs