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

400 Bad Request when creating an asset with metadata #29

Open
robert-mcgee opened this issue Mar 11, 2022 · 2 comments
Open

400 Bad Request when creating an asset with metadata #29

robert-mcgee opened this issue Mar 11, 2022 · 2 comments

Comments

@robert-mcgee
Copy link

When submitting an asset creation transaction with base64 encoded metadata the network returns a 400 Bad Request response with the following message:

{ "message": "At least one signature didn't pass verification" }

Code snippet
let tx = try! Transaction.assetCreateTransactionBuilder() .setSender(creator_address) .setAssetTotal(assetTotal: Int64(units)) .setAssetDecimals(assetDecimals: Int64(decimals)) .assetUnitName(assetUnitName: unitName) .assetName(assetName: name) .url(url: String("ipfs://\(metadataCID)#arc3")) .manager(manager: creator_address.description) .reserve(reserve: creator_address.description) .metadataHashB64(metadataHash: ("Sample metadata".data(using: .utf8)?.base64EncodedString())!) .defaultFrozen(defaultFrozen: false) .noteB64(note: ("Minted with Quick Mint for macOS".data(using: .utf8)?.base64EncodedString())!) .suggestedParams(params: paramResponse.data!) .build()

Transaction is sent successfully if I remove the metadata.

@Jesulonimi21
Copy link
Owner

@robert-mcgee
Am surprised that the Algorand network returns that error message but it turns out that the problem is with the length of the bytes of the string you are trying to use as the metadata, for example, if you used .metadataHashB64(metadataHash: "Sample metadata ".data(using: .utf8)!.base64EncodedString() you will get a successful response, i will create a PR to validate this from the SDK but that will only return the right error message, a fix you can make for this on your end might be for you to pad your string until they are 32 bytes before passing them to the sdk

@LucaInfante
Copy link

If I write:

  • metadataHashUTF8(metadataHash: )

Work.

But if I write:

  • metadataHashUTF8(metadataHash: )

Not work. I received error is > 32 byte length

But shouldn't the metadata hash in the absence of extra metadata read as sha256 while with extra metadata shouldn't it read as sha512 / 256?

What am I doing wrong?

Thanks in advance!

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