Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing init method - singleton #4

Open
quantranld opened this issue Dec 13, 2021 · 1 comment
Open

Missing init method - singleton #4

quantranld opened this issue Dec 13, 2021 · 1 comment

Comments

@quantranld
Copy link

quantranld commented Dec 13, 2021

Hi team,

Error: using singleton style, call contract init shows error as below - MethodNotFound:
export CONTRACT=dev-1639401101891-95375974097216
near call $CONTRACT init --accountId $CONTRACT
Scheduling a call: dev-1639401101891-95375974097216.init() Doing account.functionCall() Receipt: FdvybMRSR6NfqxaTftEXJ4y5GEsb9dcLD7tXomixd22f Failure [dev-1639401101891-95375974097216]: Error: Contract method is not found ServerTransactionError: Contract method is not found at Object.parseResultError (/home/quantranse/.nvm/versions/node/v16.2.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/utils/rpc_errors.js:31:29) at Account.signAndSendTransactionV2 (/home/quantranse/.nvm/versions/node/v16.2.0/lib/node_modules/near-cli/node_modules/near-api-js/lib/account.js:160:36) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async scheduleFunctionCall (/home/quantranse/.nvm/versions/node/v16.2.0/lib/node_modules/near-cli/commands/call.js:57:38) at async Object.handler (/home/quantranse/.nvm/versions/node/v16.2.0/lib/node_modules/near-cli/utils/exit-on-error.js:52:9) { type: 'MethodNotFound', context: undefined, index: 0, transaction_outcome: { proof: [ [Object] ], block_hash: 'L1J7izqs99Sd352j6gRJKRzKqpzqLzJ4eeDg97KJFbn', id: 'Ca5wtTBasYSPCKqDsSCWbFiQpJUAaXbsvPu8Y7ToG92o', outcome: { logs: [], receipt_ids: [Array], gas_burnt: 2427934415604, tokens_burnt: '242793441560400000000', executor_id: 'dev-1639401101891-95375974097216', status: [Object], metadata: [Object] } } }

Expect: can initialize the singleton contract.
Solution: I've tried to add init function to Contract class, it worked:
near call $CONTRACT init --accountId $CONTRACT
Scheduling a call: dev-1639401861183-56323128751619.init() Doing account.functionCall() Transaction Id 6zKb6yWnETT5ZVkdatPMceDNDq19x1Wz3V3QZu7MAUh5 To see the transaction in the transaction explorer, please open this url in your browser https://explorer.testnet.near.org/transactions/6zKb6yWnETT5ZVkdatPMceDNDq19x1Wz3V3QZu7MAUh5 ''

Thanks team!

@johnedvard
Copy link

I'm not completely sure what this issue is about, but I don't think it's related to this project missing the init function. If you are using the singleton pattern, try to call init on a deployed contract, you are actually trying to call the constructor.

Take a look at this StackOverflow Q&A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants