[Solved] Can't interact with smart contracts through my own node ran with docker


#1

Hello guys,

I set up a testnet node and a compiler node through docker. The command that I use for the testnet node is the following:
docker run -d --restart=always --name ae-testnet -p 3013:3013 -p 3015:3015 -v ~/.aeternity/myaeternity.yaml:/home/aeternity/.aeternity/aeternity/aeternity.yaml -v myaedb:/home/aeternity/node/data/mnesia aeternity/aeternity

and this is my configuration file:

chain:
    persist: true

peers:
    # UAT
    - aenode://[email protected]0:3015
    - aenode://[email protected].60:3015
    - aenode://[email protected].250:3015
    - aenode://[email protected]15:3015

fork_management:
    network_id: ae_uat

I’m trying to interact with the following contract using javascript SDK:

contract Identity =
  type state = ()
  function main(x : int) = x + 1
  function go(who : address) = who

This is how I interact with the contract:

const fs = require('fs')
const contractFile = fs.readFileSync('./identity.aes');
const source = contractFile.toString();

const { Universal: Ae } = require('@aeternity/aepp-sdk');
console.log(source);

Ae({ url: 'mynode:3013', internalUrl: 'mynode:3013', compilerUrl: 'mynode:3080', keypair: {
  publicKey: 'mypublickey',
  secretKey: 'mysecretkey,
}}).then(async (ae) => {
  ae.height().then(height => {
    console.log('Current Block', height);
  });

  const contract = await ae.getContractInstance(source, { contractAddress: 'ct_2XL4hnKxNXV6BAEq7Q6Dp7dP7RRqxrntY34M5DnZ4kceETUNg7' }).catch(err => { console.log(err); });
  const result = await contract.call('main', ['34'], { callStatic: true });
  console.log(result);
  const decoded = await result.decode();
  console.log(decoded);
})

SDK version is 3.1.0.
Docker image is latest.

So if I connect to https://sdk-testnet.aepps.com/ instead of my own node it works ok. When I use my node, it successfully connects and gets the blockchain height but it is unable to interact with the contract and I get the following error:
Error: While calling dryRunTxs (body), Request failed with status code 404

I believe it is something with configuration file or the way I run the container.

Appreciate your support!


#2

A support for this issue would be highly appreciated.


#3

Hello @weidex_team

you will have to enable the debug/internal endpoints in your http api:

http:
    internal:
        debug_endpoints: true
        listen_address: 0.0.0.0
        port: 3113

they are disabled by default since release 1.3.0 as not every node should have them public.

Hope this solves your issue :slight_smile:


#5

Additionally you would have to foreward port 3113 in docker and use this as internal url when you initialize your node.


#6

Works perfectly, thanks @piwo :bowing_man: