deployProxy giving Unexpected token error

I am having trouble deploying an upgradeable contract. The contract deploys just fine if I deploy regularly, but having trouble reading some artifact when doing deployProxy. Any ideas?

:computer: Environment
Truffle v5.3.4 (core: 5.3.4)
Solidity - 0.6 (solc-js)
Node v12.18.3
Web3.js v1.3.5


SyntaxError: Unexpected token . in JSON at position 1
    at JSON.parse (<anonymous>)
    at C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:25:41
    at (<anonymous>)
    at readArtifacts (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:25:27)
    at Object.validateArtifacts (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\validations.ts:16:21)
    at Object.deployImpl (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\utils\deploy-impl.ts:29:23)
    at deployProxy (C:\...\npm\node_modules\@openzeppelin\truffle-upgrades\src\deploy-proxy.ts:46:16)
    at module.exports (C:\...\2_deploy_contracts.js:5:3)
    at Migration._deploy (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:79:1)
    at Migration._load (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:61:1)
    at (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\Migration.js:212:1)
    at Object.runMigrations (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:150:1)
    at Object.runFrom (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:110:1)
    at Object.runAll (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:114:1)
    at (C:\...\npm\node_modules\truffle\build\webpack:\packages\migrate\index.js:79:1)
    at runMigrations (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:263:1)
    at (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\commands\migrate.js:228:1)
    at (C:\...\npm\node_modules\truffle\build\webpack:\packages\core\lib\command.js:140:1)

Truffle v5.3.4 (core: 5.3.4)
Node v12.18.3

:1234: Code to reproduce
deploy contract:

const { deployProxy } = require('@openzeppelin/truffle-upgrades');
var token = artifacts.require("Token");

module.exports = async function(deployer) {
  await deployProxy(token , [], { deployer, initializer: 'init' });

Can you share the list of files found in your artifacts directory? I’m assuming there’s a file in there that is not a JSON file, but I don’t know what it’s doing there.

1 Like

Thanks for the prompt response! I started playing around with it this morning and it magically worked.

It seems to work if I delete the build/contracts folder right before deploying…sometimes. I am on a windows machine and perhaps it is picking up a hidden windows file or something.

Anyway, now I am getting a new error: " Unable to update lock within the stale threshold".

I see there is a thread about that so I will comment there.

1 Like

Ok. I’ve published a new version of the Truffle plugin that will filter out non-JSON files found in the artifacts directory so this shouldn’t happen again.

1 Like