Where should the env be if I want to run "go run smartcontractd/cmd/main.go " or run"cd bin && ./smartcontractd"

I wonder where should I put my acme.env and how should I start my agent daemon (with command ./bin/smartcontractd/ or go run /smartcontractd/cmd/main.go)?

Recently I want to run one agent on centos7.6 ,so I did these:
first step:I download the binary with “go get github.com/tokenized/smart-contract/cmd/…”
second step:when I want to run the smart contract deamon ,I found that I don’t have the env files, so I download the source code because the source code contains env files example like this
“mkdir -p $GOPATH/src/github.com/tokenized
cd $GOPATH/src/github.com/tokenized
git clone tokenized/smart-contract
cd smart-contract”
third step:
"cp $GOPATH/src/github.com/tokenized/smartcontract/conf/dev.env.example ~/.config/acme.env "
and then modify acme.env ,I put my own wif key , bitcoin address and bsv node ip:port in the acme.env
forth step:“cd $GOPATH/bin” and then “./smartcontractd” but at this step I was reminded the long log message
“2020/02/23 16:59:26.110644 [Main] bootstrap.go:56 Info - Config : {
“Contract”: {
“PrivateKey”: “”,
“OperatorName”: “”,
“Version”: “”,
“FeeAddress”: “”,
“FeeRate”: 1,
“DustLimit”: 546,
“RequestTimeout”: 60000000000,
“PreprocessThreads”: 4,
“IsTest”: true
},
“Bitcoin”: {
“Network”: “mainnet”
},
“SpyNode”: {
“Address”: “127.0.0.1:8333”,
“UserAgent”: “/Tokenized:0.1.0/”,
“StartHash”: “”,
“UntrustedNodes”: 25,
“SafeTxDelay”: 2000,
“ShotgunCount”: 100
},
“RpcNode”: {
“Host”: “”,
“Username”: “”,
“Password”: “”
},
“AWS”: {
“AWS_REGION”: “ap-southeast-2”,
“AWS_ACCESS_KEY_ID”: “”,
“AWS_SECRET_ACCESS_KEY”: “”
},
“NodeStorage”: {
“Bucket”: “standalone”,
“Root”: “./tmp”
},
“Storage”: {
“Bucket”: “standalone”,
“Root”: “./tmp”
}
}
2020/02/23 16:59:26.110743 [Main] main.go:59 Info - Started : Application Initializing
2020/02/23 16:59:26.110753 [Main] main.go:62 Info - Build unknown (unknown on unknown)
2020/02/23 16:59:26.110759 [Main] main.go:67 Info - Configuring for mainnet network
2020/02/23 16:59:26.110769 [Main] bootstrap.go:87 Fatal - Invalid fee address : Address has bad checksum”
So what should I do next to go out of the situation?

I saw that there are four env examples “cli_dev.env.bat.example” ,“cli.dev.env.example”,“dev.env.bat.example”,“dev.env.example” .WIth all of these envs ,how should I modify each of them and which place should I put each of them ?
Can you help me out @KarlTheProgrammer

when I execute "./smartcontractd " the logs tell that
" 2020/02/23 19:25:14.579759 [Main] main.go:59 Info - Started : Application Initializing

2020/02/23 19:25:14.579774 [Main] main.go:62 Info - Build unknown (unknown on unknown)

2020/02/23 19:25:14.579781 [Main] main.go:67 Info - Configuring for mainnet network

2020/02/23 19:25:14.580059 [Main] main.go:116 Info - Contract address : 13yiAJMog3zDHQVo3combfZpKhbRwCvviu

2020/02/23 19:25:14.580073 [Main] main.go:128 Info - Started : Initialize Database

2020/02/23 19:25:14.580148 [Main] wallet.go:113 Info - Syncing wallet

2020/02/23 19:25:14.580254 [Main] main.go:190 Info - Node Running

2020/02/23 19:25:14.580359 [Main] tracer.go:77 Verbose - Loaded 0 traces

2020/02/23 19:25:14.580383 [Main] node.go:156 Info - Starting pre-process thread 0

2020/02/23 19:25:14.580393 [Main] node.go:156 Info - Starting pre-process thread 1

2020/02/23 19:25:14.580409 [Main] node.go:156 Info - Starting pre-process thread 2

2020/02/23 19:25:14.580415 [Main] node.go:156 Info - Starting pre-process thread 3

2020/02/23 19:25:14.580578 [SpyNode] blocks.go:113 Verbose - Adding mainnet genesis block

2020/02/23 19:25:14.580657 [SpyNode] blocks.go:135 Verbose - Added genesis block : 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

2020/02/23 19:25:14.580675 [SpyNode] node.go:112 Info - Loaded blocks to height 0

2020/02/23 19:25:14.580684 [SpyNode] node.go:118 Info - Start block not found yet

2020/02/23 19:25:14.580696 [SpyNode] transactions.go:45 Verbose - No unconfirmed txs to load

2020/02/23 19:25:14.580746 [SpyNode] node.go:151 Verbose - Connecting to 127.0.0.1:8333

2020/02/23 19:25:14.580907 [SpyNode] node.go:158 Error - Trusted connection failed to 127.0.0.1:8333 : dial tcp 127.0.0.1:8333: connect: connection refused

2020/02/23 19:25:19.581066 [SpyNode] node.go:153 Verbose - Re-connecting to 127.0.0.1:8333

2020/02/23 19:25:19.581288 [SpyNode] node.go:158 Error - Trusted connection failed to 127.0.0.1:8333 : dial tcp 127.0.0.1:8333: connect: connection refused

2020/02/23 19:25:24.582173 [SpyNode] node.go:153 Verbose - Re-connecting to 127.0.0.1:8333

2020/02/23 19:25:24.582461 [SpyNode] node.go:158 Error - Trusted connection failed to 127.0.0.1:8333 : dial tcp 127.0.0.1:8333: connect: connection refused

2020/02/23 19:25:29.583195 [SpyNode] node.go:153 Verbose - Re-connecting to 127.0.0.1:8333"

why 127.0.0.1:8333 refused?

maybe four env files will make me exploding

The files starting with “cli” are for the CLI (Command Line Interface) program smartcontract. The files that don’t start with “cli” are for the daemon/service program smartcontractd. The files with “.bat” in them are windows batch files and those without are linux files. The location of the environment files does not matter. You just need to load it in the terminal that you are executing the program in so it can see the environment variables that you specified. In windows you just execute the .bat file. In linux you run the source command followed by the name of the file to source it into your environment.

The NODE_ADDRESS and RPC_HOST addresses must point to a full bitcoin node configured with RPC access for you so smart-contract can pull data and monitor the block chain. If you are not running a full bitcoin node on your machine (localhost address 127.0.0.1) then that is why you are getting the connection refused error.

I’m running one BSV full node on my own machine,its rpc port is 8332 ,just like the RPC_HOST=127.0.0.1:8332 ,I’m still reminded that
“2020/02/23 19:25:19.581066 [SpyNode] node.go:153 Verbose - Re-connecting to 127.0.0.1:8333
2020/02/23 19:25:19.581288 [SpyNode] node.go:158 Error - Trusted connection failed to 127.0.0.1:8333 : dial tcp 127.0.0.1:8333: connect: connection refused”
it seems that not about rpc port 8332,so why 8333 connection refused?

Smart contract needs both RPC, port 8332, and standard bitcoin P2P, port 8333. You might need to add listen=1 to your bitcoin config file so it will accept incoming P2P connections.

what should my bsv full node p2p port be? I install my bsv node with docker and I can expose my p2p port to agent

The P2P port will be 8333 unless you configured it to something else. I am not very familiar with docker. It might have a different IP than your local machine, which could be the issue.

oh I see,8333 is my p2p port .Now I meet this issue and I will expose it very soon.And another when I “cd $GOPATH/bin” and “./smartcontract sync” it reminded me “Failed to open log file : open : no such file or directory”.
and when I do something else like " ./smartcontract build C1 acme.json --hex" or “./smartcontract build A1 acme_asset_definition.json --tx” ,I was also reminded the same message
“Failed to open log file : open : no such file or directory”.
what is the reason?

I usually see that error when I forgot to source the config file, because the path to the log file is undefined and that is one of the first things it attempts. Make sure you either run the bat config file on Windows, or source it on Linux.

I source the env every time after I vi ,so maybe some other reasons, now I’m exposing my p2p port to agent

what time is it now? your clock so I can figure out the best time to get you

I am usually online during UTC+10 business hours.

ok, before I do “./smartcontract build A1 acme_asset_definition.json --tx --send”,should I must do “./smartcontract build C1 acme_contract_definition.json --tx”? I must define one contract on my MasterAddress before I define my currency on my MasterAddress?

Now I have “./smartcontract sync” successfully and I can see the contract address’s bsv balance is correct.
I vi my acme_contract_definition.json and I
“./smartcontract build C1 acme_contract_definition.json --tx” to send it to BSV network ,I can see the Txid but when I lookup it on whatsonchain ,I can’t find it on chain ? What may be the reason?

Yes, you must first define the contract with C1 before defining any assets.

It is not on the “master address” though. The master address in C1 should be associated with a key that is in cold storage and used for emergency recovery only when the contract address is compromised.

The contract address is the address you send the C1 tx to. It should be in the first output of the C1 tx. It is the address that the smart contract agent is configured to run on.