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

minting example #135

Closed
wants to merge 2 commits into from
Closed

minting example #135

wants to merge 2 commits into from

Conversation

andrewkmin
Copy link
Collaborator

Summary & Motivation

How I Tested These Changes

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 16, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

address: "0x85111DF47D97Cc1aB3e76889fCF08594d053E85d",
functionName: "mint",
chain: goerli,
account,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call will succeed if account is omitted. However, if included, it leads to:

/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getTransactionError.js:11
    return new transaction_js_1.TransactionExecutionError(cause, {
           ^

TransactionExecutionError: The method does not exist / is not available.

URL: https://goerli.infura.io/v3/84842078b09946638c03157f83405213
Request body: {"method":"eth_sendTransaction","params":[{"data":"0x1249c58b","from":"0xd1FE65c7925f56594277bdb22FbFC4a2cB613514","to":"0x85111DF47D97Cc1aB3e76889fCF08594d053E85d"}]}
 
Request Arguments:
  chain:  Goerli (id: 5)
  from:   0xd1FE65c7925f56594277bdb22FbFC4a2cB613514
  to:     0x85111DF47D97Cc1aB3e76889fCF08594d053E85d
  data:   0x1249c58b

Details: The method eth_sendTransaction does not exist/is not available
Version: [email protected]
    at getTransactionError (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getTransactionError.js:11:12)
    at sendTransaction (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/actions/wallet/sendTransaction.js:77:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at writeContract (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/actions/wallet/writeContract.js:12:18)
    at main (/Users/andrew/tkhq/code/sdk/examples/with-viem/src/contracts.ts:49:16) {
  details: 'The method eth_sendTransaction does not exist/is not available',
  docsPath: undefined,
  metaMessages: [
    'URL: https://goerli.infura.io/v3/84842078b09946638c03157f83405213',
    'Request body: {"method":"eth_sendTransaction","params":[{"data":"0x1249c58b","from":"0xd1FE65c7925f56594277bdb22FbFC4a2cB613514","to":"0x85111DF47D97Cc1aB3e76889fCF08594d053E85d"}]}',
    ' ',
    'Request Arguments:',
    '  chain:  Goerli (id: 5)\n' +
      '  from:   0xd1FE65c7925f56594277bdb22FbFC4a2cB613514\n' +
      '  to:     0x85111DF47D97Cc1aB3e76889fCF08594d053E85d\n' +
      '  data:   0x1249c58b'
  ],
  shortMessage: 'The method does not exist / is not available.',
  version: '[email protected]',
  cause: /Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/buildRequest.js:40
                      throw new rpc_js_1.MethodNotFoundRpcError(err);
                            ^
  
  MethodNotFoundRpcError: The method does not exist / is not available.
  
  URL: https://goerli.infura.io/v3/84842078b09946638c03157f83405213
  Request body: {"method":"eth_sendTransaction","params":[{"data":"0x1249c58b","from":"0xd1FE65c7925f56594277bdb22FbFC4a2cB613514","to":"0x85111DF47D97Cc1aB3e76889fCF08594d053E85d"}]}
  
  Details: The method eth_sendTransaction does not exist/is not available
  Version: [email protected]
      at delay.count.count (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/buildRequest.js:40:27)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at attemptRetry (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/promise/withRetry.js:15:30) {
    details: 'The method eth_sendTransaction does not exist/is not available',
    docsPath: undefined,
    metaMessages: [
      'URL: https://goerli.infura.io/v3/84842078b09946638c03157f83405213',
      'Request body: {"method":"eth_sendTransaction","params":[{"data":"0x1249c58b","from":"0xd1FE65c7925f56594277bdb22FbFC4a2cB613514","to":"0x85111DF47D97Cc1aB3e76889fCF08594d053E85d"}]}'
    ],
    shortMessage: 'The method does not exist / is not available.',
    version: '[email protected]',
    cause: /Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/clients/transports/http.js:40
                        throw new request_js_1.RpcRequestError({
                              ^
    
    RpcRequestError: RPC Request failed.
    
    URL: https://goerli.infura.io/v3/84842078b09946638c03157f83405213
    Request body: {"method":"eth_sendTransaction","params":[{"data":"0x1249c58b","from":"0xd1FE65c7925f56594277bdb22FbFC4a2cB613514","to":"0x85111DF47D97Cc1aB3e76889fCF08594d053E85d"}]}
    
    Details: The method eth_sendTransaction does not exist/is not available
    Version: [email protected]
        at request (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/clients/transports/http.js:40:27)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
        at delay.count.count (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/buildRequest.js:30:20)
        at attemptRetry (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/promise/withRetry.js:15:30) {
      details: 'The method eth_sendTransaction does not exist/is not available',
      docsPath: undefined,
      metaMessages: [Array],
      shortMessage: 'RPC Request failed.',
      version: '[email protected]',
      cause: [Object],
      code: -32601
    },
    code: -32601
  }
}

address: "0x85111DF47D97Cc1aB3e76889fCF08594d053E85d",
functionName: "mint",
chain: goerli,
account,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, if account is included, it'll lead to the same error as above ^. If omitted, simulation actually runs, but with the assumption that the destination address is null/zero (since this is using the publicClient):

/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getContractError.js:28
    return new contract_js_1.ContractFunctionExecutionError(cause, {
           ^

ContractFunctionExecutionError: The contract function "mint" reverted.

Error: MintToZeroAddress()
 
Contract Call:
  address:   0x85111DF47D97Cc1aB3e76889fCF08594d053E85d
  function:  mint()

Docs: https://viem.sh/docs/contract/simulateContract.html
Version: [email protected]
    at getContractError (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getContractError.js:28:12)
    at simulateContract (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/actions/public/simulateContract.js:44:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at main (/Users/andrew/tkhq/code/sdk/examples/with-viem/src/contracts.ts:64:23) {
  details: undefined,
  docsPath: '/docs/contract/simulateContract',
  metaMessages: [
    'Error: MintToZeroAddress()',
    ' ',
    'Contract Call:',
    '  address:   0x85111DF47D97Cc1aB3e76889fCF08594d053E85d\n' +
      '  function:  mint()'
  ],
  shortMessage: 'The contract function "mint" reverted.',
  version: '[email protected]',
  cause: /Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getContractError.js:21
          cause = new contract_js_1.ContractFunctionRevertedError({
                  ^
  
  ContractFunctionRevertedError: The contract function "mint" reverted.
  
  Error: MintToZeroAddress()
  
  
  Version: [email protected]
      at getContractError (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/utils/errors/getContractError.js:21:17)
      at simulateContract (/Users/andrew/tkhq/code/sdk/node_modules/.pnpm/[email protected][email protected]/node_modules/viem/dist/cjs/actions/public/simulateContract.js:44:41)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at main (/Users/andrew/tkhq/code/sdk/examples/with-viem/src/contracts.ts:64:23) {
    details: undefined,
    docsPath: undefined,
    metaMessages: [ 'Error: MintToZeroAddress()', '' ],
    shortMessage: 'The contract function "mint" reverted.',
    version: '[email protected]',
    data: {
      abiItem: [Object],
      args: undefined,
      errorName: 'MintToZeroAddress'
    },
    reason: undefined,
    signature: undefined
  },
  ...

@andrewkmin andrewkmin closed this Oct 17, 2023
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

Successfully merging this pull request may close these issues.

1 participant