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

Can not pass array variable to create_program_address() #1662

Open
YanhuiJessica opened this issue Aug 15, 2024 · 3 comments
Open

Can not pass array variable to create_program_address() #1662

YanhuiJessica opened this issue Aug 15, 2024 · 3 comments

Comments

@YanhuiJessica
Copy link

Describe the bug

error: conversion from bytes[] to bytes[] not possible
  ┌─ test.sol:9:39
  │
9 │         return create_program_address(seeds, token);

To Reproduce
Compile the attached source code with solang compile --target solana test.sol

Expected behavior
create_program_address() should be able to accept array variables.

Hyperledger Solang version
v0.3.3

Include the complete solidity source code
The following example is derived from the documentation.

import {create_program_address} from 'solana';
contract pda {
    address token = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
    function create_pda(bytes seed2) public returns (address) {
        bytes[] seeds = ["kabang", seed2];
        return create_program_address(seeds, token);
    }
}

image

@YanhuiJessica
Copy link
Author

Same as try_find_program_address()

@seanyoung
Copy link
Contributor

That does look like an issue. However, in the mean time you can do it like so:

import {create_program_address} from 'solana';
contract pda {
    address token = address"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
    function create_pda(bytes seed2) public returns (address) {
        return create_program_address(["kabang", seed2], token);
    }
}

@YanhuiJessica
Copy link
Author

yeah, not a big issue. However, working with variables is sometimes more flexible.

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